开发者

add active class using jquery [closed]

开发者 https://www.devze.com 2023-04-12 21:32 出处:网络
开发者_如何转开发 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current for
开发者_如何转开发 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.
         <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 advance


I 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消