javascript - How to highlight menu button? -


i need highlight menu button when selecting menu item. if select menu item need apply current class (li).

this have tried.

here html,

  <ul>      <li class="current"><a href="#">home</a></li>      <li><a href="#">service</a></li>      <li><a href="#">aboutus</a></li>      <li><a href="#">profile</a></li>      <li><a href="#">contactus</a></li>   </ul> 

here jquery,

var opener = {   init:function()  {           this.menuselection();    },    menuselection:function(){     $('ul li a').on('click', function (){         $('ul li').addclass('current');     });    } } opener.init(); 

here css,

.current {   color: #03c9a9; } a, a:active, a:focus {   color: #fff; } a, a:hover, a:active, a:focus {   outline: 0;   border: 0;   text-decoration: none;   color: #fff; } 

demo

use this, small correction in prev comment

 $('ul li a').on('click', function (){         $('ul li a').removeclass('current');          $(this).addclass('current');      });


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -