tags:

views:

48

answers:

2

How would I go about targeting the below img with the src file?

<img src="left1.gif" alt="" />

$('img[src=left1.gif]').hide(); doesn't work

+4  A: 

Your HTML says left1.gif, but your jQuery says lift1.gif. Note also the quotes around my value:

$("img[src='left1.gif']").hide();
Jonathan Sampson
Sorry, typo there, fixed now
Keith Donegan
+3  A: 

You need to put quotes around the string value of src in your selector. This helps resolves ambiguities with special characters, and seems to apply to the . in the filename.

$("img[src='left1.gif']").hide();
zombat
Thanks Zombat, you saved me a few more hairs on my head :)
Keith Donegan
Np, I've run into that one before. I've trained myself to always quote all attribute selector values now ;)
zombat