Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 15th, 2012  |  syntax: None  |  size: 0.45 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. In best case how can I check a link belongs to *.domain.com?
  2. // regular expression to check for domain.com
  3. // won't match tricky ones like domain.company.com nodomain.com :)
  4. var re = /(^|.)domain.com(/|$)/i;
  5.  
  6. // loop through all the links
  7. $("a").each(function() {
  8.   // test if href attribute belongs to domain.com
  9.   if(re.test($(this).attr('href'))) {
  10.     // do what you want with links that belong to domain.com
  11.     $(this).addClass("domaincom");
  12.   }
  13. });