JQuery: How to find an image by its src

jquery

I need to find an img by name and src. I have been trying the following to no avail.

var s = $("img[src='/images/greendot.gif'][name='BS']");

The html:

<img alt="This item is active." name="BS" src="/images/greendot.gif"/>

vs

<img alt="This item is not active." name="BS" src="/images/spacer.gif"/>

Best Solution

without seeing the html I would say check your path.

$("img[src$='greendot.gif'][name='BS']")

given the following HTML:

<img src="http://assets0.twitter.com/images/twitter_logo_header.png" name="logo" />

this jquery worked:

var x = $("img[src$='twitter_logo_header.png'][name='logo']");
alert(x.attr("src"));