How can I find all elements without a certain data-attribute?
I've tried:
$list.find('li:not([data-stuff])');
But it doesn't work.
jQuery stores data attributes in its cache, so you need to use filter:
var $li = $list.filter(function() {
return $(this).data('stuff') != undefined;
});
// do something with $li...
data('suff')!=undefined else falsy values like false and 0 will failI think what you're looking for is:
$list.find('li').not('li[data-stuff]').addClass('foo');
The addClass() is just there as a placeholder.
$listelement, can you share the html as well