+ 1
Is there a direct way to change class of currently selected li elements?
Is there a direct way to change class of currently selected li elements?
4 odpowiedzi
+ 4
e.target.classList.add("className"); or this.classList.add("className");
you can use this or e.target to select current element.
+ 2
var element = document.getElementById("myDIV");
element.classList.add("mystyle");
This is from w3schools.com
+ 1
thanks for answering. 😁
+ 1
$( "li a" ).click(function( event ) {
$('#host_panel').empty();
$('a').removeClass()
$('a').addClass('nav_anchor');
$(this).addClass('changed_anch')
});
I did it in this way.