Toggle classes using JQuery

Posted by Rajnilari2015 under jQuery category on | Points: 40 | Views : 282
Let say we have two hyper links Home and Search.The Home is initially having Active as class . When the Search is clicked , the Active class of Home will be removed and set to Search and vice versa. The below code will do that

<script type='text/javascript' src=''></script>
<script type="text/javascript">

$(document).ready(function () {

$("ul#tabs li").click(function (e) {
$('ul#tabs li').toggleClass('active');

<div id="divMenuTab">
<ul id="tabs">
<li class="active"><a href="javascript:alert('test1')" id="aTabDocuments" > <span></span>Home</a></li>
<li><a href="javascript:alert('test2');" id="aTabSearch"><span></span>Search</a></li>


Comments or Responses

Login to post response