Reputation: 321
In my document, I have this:
<ul id='IDul_weekSelector' class='pagination pagination-sm>
<li ><a href='#' status='enabled'>11</a></li>
<li ><a href='#' status='enabled'>12</a></li>
<li ><a href='#' status='enabled'>13</a></li>
<li ><a href='#' status='enabled'>14</a></li>
<li ><a href='#' status='enabled'>15</a></li>
<li ><a href='#' status='enabled'>16</a></li>
<li class='active'><a href='#' status='enabled'>17</a></li>
</ul>
On click I enter a function and read the week, $(this).text(). I want to change that clicked element's class to active which I can do.
Question is, how do I find the element that was shown as 'active' before the click and change it? I can't have two concurrent 'active' list elements.
Thank you.
Upvotes: 0
Views: 30
Reputation: 517
You can find it using $('#IDul_weekSelector li.active');
to return the li element with active class inside your ul.
You can use $('#IDul_weekSelector li.active').removeClass('active');
to solve your problem.
Upvotes: 1