I’m trying to get a jQuery selector to return all the images that don’t have a certain src.
$('img[src!="/img/none.png"]')
These images are already transparent so, for performance sake I'm trying to exclude them from the ones that I fade in/out. But the query still returns the images with src = /img/none.png
If however I do
$('img[src="/img/none.png"]')
It will return only the images with src = /img/none.png. So it seems like the attribute not equal selector is broken?
Relevant documentation http://api.jquery.com/attribute-not-equal-selector/
Answer: Use the jQuery attr() Method You can use the attr() method to change the image source (i.e. the src attribute of the <img> tag) in jQuery. The following example will change the image src when you clicks on the image.
try
$('img:not([src="/img/none.png"])');
If that doesn't work, try
$('img:not([src$="/img/none.png"])');
depending on what browser you're in, the src isn't interpreted as what you set, it's interpreted as the absolute URI, so your browser thinks it's http://www.yoursite.com/img/none.png
. I'm not sure how jQuery is reading the src so it may be picking up the absolute URI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With