如何仅更改单击的链接内的元素?
我以为这样的孩子会工作,但没有运气。
$('.sort').click(function () {
$(this).children('i').toggleClass('icon-arrow-up-12');
});
最佳答案
使用find
(api.jquery.com/find),如下所示:
$(this).find('i').toggleClass('icon-arrow-up-12');
如何仅更改单击的链接内的元素?
我以为这样的孩子会工作,但没有运气。
$('.sort').click(function () {
$(this).children('i').toggleClass('icon-arrow-up-12');
});
最佳答案
使用find
(api.jquery.com/find),如下所示:
$(this).find('i').toggleClass('icon-arrow-up-12');