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"/>
You can use a data attribute to mark the image as selected. You can also add a class to visually show that it is selected. Show activity on this post. i.e.
Use the getAttribute() method to check if an image src is empty, e.g. img. getAttribute('src') . If the src attribute does not exist, the method returns either null or empty string, depending on the browser's implementation.
To use an image on a webpage, use the <img> tag. The tag allows you to add image source, alt, width, height, etc. The src is to add the image URL. The alt is the alternate text attribute, which is text that is visible when the image fails to load.
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"));
Try losing the quotes:
var s = $("img[src=../../images/greendot.gif][name=BS]");
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