Home  >  Article  >  Web Front-end  >  jquery中toggle函数交替使用问题_jquery

jquery中toggle函数交替使用问题_jquery

WBOY
WBOYOriginal
2016-05-16 15:53:361429browse

html中有几个btn触发toggle函数,想要实现的功能是:点击每个toggle时将其他toggle函数的计数全部清零,试过removedata不起作用,是否有更好的办法呢

给大家一个实例来参考下吧

请参考这个:jsp页面

<li>
<label class="labelText">统计类型:</label>
<span class="sortBox">
<a href="javascript:;" data-type="subject">按学科统计</a>
<a href="javascript:;" data-type="classlevel">按年级统计</a>
<a href="javascript:;" data-type="lower">按下级统计</a>
</span>
</li>

js代码:

$('.sortBox').on('click', 'a', function () {
$(this).addClass('selected').siblings().removeClass('selected');
}) ;
$('.sortBox a')[0].click();

以上所述就是本文的全部内容了,希望大家能够喜欢。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn