I've the following html code
<ul class='selectul'>
<li class='active'><a href='?sortby=views'>by Popularity.</a></li>
<li><a href='?sortby=recency'>by Recency.</a></li>
<li><a href='?sortby=alphabet'>Alphabetically.</a></li>
</ul>
When any <li> element is clicked, I want to add class='active' to it. None of its siblings is then allowed to have this class. I tried to do this with the following jQuery code
(function(){
$('.selectul li').on('click',function(){
$(this).addClass('active');
$(this).siblings().removeClass('active');
});
}())
but it doesn't seem to do anything. I'm just getting started with jQuery so I apologize if this question is rather basic.
$(this).addClass('active').siblings().removeClass('active');