javascript - How to write js or css for deleting class and writing class when you click another -


<nav class="mynav">     <ul id="mynavigation">         <li><a class="active" href="#hm">main</a></li> /* active class */         <li><a href="#pj">projects</a></li>         <li><a href="#port">port</a></li>         <li><a href="#contact">contact</a></li>     </ul> </nav> 

how write css or js for....

if click projects (tag a) code should working this

<nav class="mynav">     <ul id="mynavigation">         <li><a class="" href="#hm">main</a></li>         <li><a class="active" href="#pj">projects</a></li>  /* active class */         <li><a href="#port">port</a></li>         <li><a href="#contact">contact</a></li>     </ul> </nav> 

step
1.delete class='active' in id='mynavigation'
2.put class='active' in tag click in id='mynavigation'

using jquery's removeclass , addclass methods

$('#mynavigation li a').click(function(){   $('#mynavigation li a').removeclass('active');   $(this).addclass('active') }); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -