我正在使用这个:
$(this).parent('label').parent('li').parent('ul').find('img').removeClass('selectedRadio');
除了使用父级 3 次之外,我怎样才能压缩它?
最佳答案
使用closest而不是束缚 parent :
$(this).closest('ul').find('img').removeClass('selectedRadio');
关于jquery - 如何简化这个 jQuery 选择器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6160246/