开发者

"toggleClass" in my accordion

开发者 https://www.devze.com 2023-01-21 14:03 出处:网络
I have written a jquery script here But there is problem in the $(this).toggleClass(\"active\").next(); section. With this al开发者_StackOverflow社区l the header tags will be in \"active\" class. How

I have written a jquery script here But there is problem in the $(this).toggleClass("active").next(); section. With this al开发者_StackOverflow社区l the header tags will be in "active" class. How can I assign "active" class only for clicked tag? Thanks in advance


You can remove it from the previously clicked headers by calling .removeClass() on the .siblings(), like this:

$(this).toggleClass("active").siblings().removeClass("active");

You can test it out here.

0

精彩评论

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