I have a whole list of link elements. Each class is assigned. Clm and different id. And there are classes in CSS with exactly the same names as id, but by default they are turned off. It is necessary to make it so that when you click on the link, the name id is somehow pulled into a variable and for .back-image (the class where the background changes) an additional class of those hidden {addClass (this.id)} is added. include a class with the same name. Some code. CSS:
//по умолчанию они нигде не присвоены, назовем их "скрытые". .arts{ background: url("../images/arts.svg") no-repeat center center; } .video{ background: url("../images/video.svg") no-repeat center center; }
(x) HTML:
<a xlink:href="#" id="arts" class="clm">Arts</a> <a xlink:href="#" id="video" class="clm">Video</a> <div class="back_img"></div> //там меняется фон, который добавляется из какого-либо скрытого класса
My cripple js:
$(document).ready(function(){ $('.clm').клик(получить его id) }); $('.clm').click(function()){ $('.back_img').addClass(класс с именем как и у id) } });