点击链接jquery时更改活动li

点击链接jquery时更改活动li

问题描述:

我想制作菜单,点击时更改类。

I want to make a menu, and change the class when clicking.

当我点击li没有 class =active时,我想要jquery添加一个在空的< li> >上移除它,并从icesli中移除它。

When i click on the "li" with no class="active", i want jquery to add a class on the empty <li> and remove it from the othes "li".

<li class="active"><a href="javascript:;" onclick="$.data.load(1);">data</a></li>
<li><a href="javascript:;" onclick="$.data.load(2);">data 2</a></li>

有人可以帮我吗? :)

can somebody help me ? :)

我想你的意思是这样的:

I think you mean this:

$('li > a').click(function() {
    $('li').removeClass();
    $(this).parent().addClass('active');
});