I know that I get an element(s) by attribute via, eg
$('.js_aBunchOfElements span[data-stuff="special"]');
Yet once I store the selector in a variable:
var bunch = $('.js_aBunchOfElements span');
I am confused how to search within bunch
for my elements with the attribute data-stuff="special"
.
bunch.filter('[data-stuff=special]')
应该这样做。
bunch.filter(function() {
return $(this).attr("data-stuff") == "special";
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.