So I have something that looks like this:
<src id="Point_1" href="pin_icon_red_attack.png">
Why doesn’t this JQuery work?:
if( $('img[id*="Point_"][src="pin_icon_red_attack.png"]') ) {
// do something
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This selector looks for an image with an href of
pin_icon_red_attack.pngthat’s inside an image with an id that containsPoint_.Also, in HTML, the tag is
<img>, not<image>, and it’ssrc=nothref=.It should be:
Also, in the if statement you need to add
.length, because when jQuery finds nothing, it returns a blank array (which JavaScript evaluates totrue).DEMO: http://jsfiddle.net/usjz6/3/
NOTE: If the ID always starts with
Point_you can use[id^="Point_"](starts with) instead of[id*="Point_"].