How to make it so that when you click on a drawing, it changes when you help the toggle function, or rather, when you click it, it changed the class? I use it for the player. ATP for help.
- @abdujalil Do not use translit. - Nicolas Chabanovsky ♦
|
3 answers
$('#risunok').click(function(){ $(this).toggleClass('class1 class2'); }); - Does this feature replace classes even if there are several? - culebre
- It does not replace, but "switches". There may be several classes and they should go through the gap. - ling
|
$('selector').toogleClass('class')- Adds a class if it does not exist, and deletes if it exists. There are also methods:$('selector').hasClass('class')- returns true if there is a class class, false if not. There are also methods:$('selector').addClass('class')- adds a class.$('selector').removeClass('class')- will remove the class class.
|
$(selector).css("property","value"); Установит всем найденным по селектору элементам свойство property:value $(selector).css("property") //Вернет значение свойства css The $ .toggle () function toggles item visibility.
|