<ul>
<li id="db" onclick="loadSlide('db_content')">Database</li>
<li id="xp" onclick="loadSlide('xp_content')">Xpath</li>
<li id="con" onclick="loadSlide('con_content')">Controller</li>
</ul>
This is the code and I want to add active class.
Please note that there is no a tag. Now how can I add active class to li Thanks in advanceI think this is more relative and reliable.
$('ul li').click(function(){
$(this).addClass('someClassName');
})
Actually I didnt understand that what do you mean with active class but you can use this for adding class to an element
$('li').addClass('someClassName');
according to your comment earlier:
$("ul li").click(function() {
$(this).siblings().removeClass('activeClass');
$(this).addClass('activeClass');
});
and define the style in someClass
.
精彩评论