The alternate use of toggle functions in jquery

  • 2020-06-19 09:40:54
  • OfStack

Several btn trigger toggle functions in html. The function you want to achieve is: click on each toggle to clear the count of other toggle functions. If removedata doesn't work, is there a better way

Let me give you an example

Please refer to this: jsp page


<li>
<label class="labelText"> Statistical Type: </label>
<span class="sortBox">
<a href="javascript:;" data-type="subject"> Statistics by subject </a>
<a href="javascript:;" data-type="classlevel"> Statistics by Grade </a>
<a href="javascript:;" data-type="lower"> Count by rank </a>
</span>
</li>

js code:


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

This is the end of this article, I hope you enjoy it.


Related articles: