Selecting within link attributes
by Joe Saad
HTML
<a href="https://www.google.com">Google.com</a>
<a href="mailto:[email protected]">mailto</a>
<a href="null" onclick="javascript:displayIt();">onClick</a>
<a href="null" class="happy boy">Happy</a>
<a href="null" class="sad boy">sad</a>
JavaScript
var avoidhref = /http|mailto/i;
var avoidRule = /happy|sad/i;
$(function(){
$('a').each(function(){
if (avoidhref.test($(this).attr('href')) || (avoidRule.test($(this).attr('class')) ))
{
alert($(this).text()+ 'found');
}
else {
alert('np');
}
});
});