I'm trying to select all elements that have a data-go-to
attribute that is not empty.
I've tried $('[data-go-to!=""]')
but oddly enough it seems to be selecting every single element on the page if I do that.
I'm trying to select all elements that have a data-go-to
attribute that is not empty.
I've tried $('[data-go-to!=""]')
but oddly enough it seems to be selecting every single element on the page if I do that.
This works for me
Try this :
Using
:not
,.not()
,:empty
etc will only check if the element itself is empty, not the data attribute. For that you will have to filter based on the data attributes value.FIDDLE
This works for me:
I'm not sure about a simple selector, but you could use
filter()
:JS Fiddle demo.
References:
filter()
.Has 'data-attributename' and its value is not empty:
Has 'data-attributename' empty or not:
JS Fiddle example