0

can anyone tell me ho do i write code for add remove class on click in navigation

jjx

11th Apr 2017, 9:10 AM
Binod Nakhan
Binod Nakhan - avatar
2 Answers
+ 1
// to add class: var d = document.getElementByTagName("nav"); d.className += " newclass"; // to remove class: d.className = d.className.replace ("newClass","");
11th Apr 2017, 9:45 AM
CalviŐČ
CalviŐČ - avatar
0
I'm using w3.js library, in which it's just w3.addClass("#id","classname"); and w3.removeClass("#id","classname"); HTML: <head> <link rel="stylesheet" href="example.css> </head> <body> <nav> <div id="nav1" onclick="w3.addClass("#nav1", "navClicked")">Something in here</div> </nav> <script src="w3.js"></script> </body>
11th Apr 2017, 9:41 AM
Kuba Nawieƛniak
Kuba Nawieƛniak - avatar