Home  >  Article  >  Web Front-end  >  Problems with the alternate use of toggle functions in jquery_jquery

Problems with the alternate use of toggle functions in jquery_jquery

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

There are several btn triggering toggle functions in HTML. The function I want to achieve is: when each toggle is clicked, all the counts of other toggle functions will be cleared. I tried removedata but it doesn't work. Is there a better way

Let me give you an example for reference

Please refer to this: jsp page

<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 code:

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

The above is the entire content of this article, I hope you all like it.

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