![](/img/trans.png)
[英]Multiple elements with the same class, get the text of only the clicked element
[英]On click only apply class to element clicked, not all elements with the same class
我有一组手风琴式的过滤器。 当用户单击过滤器标题之一时,我只想显示该元素适合。 我的问题是,当我单击元素标题以显示过滤器时,所有其他类也会更改。
$('.filter-group__title').on('click', function () {
$(".glyphicon").toggleClass("glyphicon-minus glyphicon-plus");
});
您应该用“ this”来指代父母
$('.filter-group__title').on('click', function () {
$(this).find(".glyphicon").toggleClass("glyphicon-minus glyphicon-plus");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.