Is there a direct way to change class of currently selected li elements? | Sololearn: Learn to code for FREE!

+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?

2/11/2018 10:54:54 AM

ISHTIAQUE BIN IDREES

4 Answers

New Answer

+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.