
Untitled
By: a guest on
May 15th, 2012 | syntax:
None | size: 0.45 KB | hits: 11 | expires: Never
In best case how can I check a link belongs to *.domain.com?
// regular expression to check for domain.com
// won't match tricky ones like domain.company.com nodomain.com :)
var re = /(^|.)domain.com(/|$)/i;
// loop through all the links
$("a").each(function() {
// test if href attribute belongs to domain.com
if(re.test($(this).attr('href'))) {
// do what you want with links that belong to domain.com
$(this).addClass("domaincom");
}
});