문제

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

도움이 되었습니까?

해결책

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();

다른 팁

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

$("img[src='left1.gif']").hide();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top