Reputation: 65
How do i do a JQUERY select for this:
All images that have a title that does not have the word “dog” in it
I can select all images that have a title with this code:`
$('img[title]')
i have done this but its not working:
$('img[title]:not(title~="dog")')
or
$('img[title~="dog"]:not()')
or
$('img[title~="dog"]') //this selects the one with dog, but how do i do oposite of this
Upvotes: 2
Views: 24
Reputation: 171669
Try:
$('img[title]:not([title~="dog"])')
you were close but the attribute part needs to be wrapped in []
An alternative is use filter()
$('img[title]').filter(function(){
return this.title.indexOf('dog') === -1;
});
Upvotes: 1