Select onclick that contains _blank

i select links with empty target to set title attribute

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

      

which is working.

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 this:

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

      

+1


source to share


3 answers


Use the code below:



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

      

+2


source


This seems to work for me using Attribute contains selector -

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

      



Could you use this?

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

0


source


found which contains * and not ~

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

      

0


source







All Articles