开发者

How to select the IMG tag based on the attribute?

<IMG 开发者_运维问答height="160" alt="Web Content Image" src="../image/journal/article?img_id=16505&t=1273484793531" width="240" pngSet /> 

I have the this code for the image , and I want to select the image based on the attribute "pngSet"

I am trying this , but not working.

$("img[pngSet='']").css('border' ,'1px solid red');


You can do it like this:

 $("img[pngSet]").css('border' ,'1px solid red');

The has attribute selector is just [attributeName] :)


Should be:

$('img[pngSet]')


Give this a shot (using the has attribute selector):

$("img[pngSet]")


$("img[pngSet]");


It's usually a bad idea to make up attributes. Browsers don't have to support it. Best would be to use a class instead:

<IMG height="160" alt="Web Content Image" src="../image/journal/article?img_id=16505&t=1273484793531" width="240" class="pngSet" /> 
$("img.pngSet").css('border' ,'1px solid red');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜