Shpigford Shpigford - 10 months ago 47
jQuery Question

jQuery: Select data attributes that aren't empty?

I'm trying to select all elements that have a

attribute that is not empty.

I've tried
but oddly enough it seems to be selecting every single element on the page if I do that.

Answer Source




For the sake of not leading anyone astray, this answer will work in older versions of jQuery but is not future-proof. Since @gmo and @siva's answers both seem to be working with later versions I defer to (and encourage you to upvote) their answers....and of course hope you have a fantastic day.