$("a[href^='http']").each(function() { var domainname = $(this).attr('href').replace('http:\/\/', ''); $(this).css({ background: "url(http://www.google.com/s2/favicons?domain=" + domainname + ") left center no-repeat", "padding-left": "20px" }); });
a { display: block; text-decoration: none; padding: 5px; }
<a href=http://github.com>GitHub</a> <a href=http://css-tricks.com>CSS-Tricks</a> <a href=http://www.google.com>Google</a> <a href=http://jsfiddle.net/chriscoyier/6Vg7t/3/>JSfiddle</a> <a href=http://kachibito.net>kachibito</a>