开发者

select onclick that contains _blank

i select links with a blank target to set a title attribute

jQuer开发者_C百科y('a[target~="_blank"]').attr('title', 'New window');

that works.

But when i select the onclick attribute that doesn't work

jQuery('a[onclick~="_blank"]').attr('title', 'New window');

any clues?

the link looks like that:

<a onclick="javascript:this.target=&quot;_blank&quot;" title="" href="http://link.com">link</a>


Use below code :

jQuery('a[onclick*="_blank"]').attr('title', 'New window');


found that contains is * and not ~

jQuery("a[onclick*='_blank']").attr('alt', 'New window');


This seems to work for me using the Attribute Contains Selector -

$("a[onclick*='_blank']")

Could you use that instead?

Demo - http://jsfiddle.net/uZaCW/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜