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="_blank"" 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/
精彩评论