Reputation: 55
I have a little problem, I want to hide some of feched images. Like gravatar and small images. Can someone give me an example of regex function? How to hide images like this:
<ul id="grid"><li><img id="photo" src="http://www.gravatar.com/avatar.php?gravatar_id%3D9698b3c319a46d14567b271cabcc85f1%26amp%3Brating%3DX%26amp%3Bsize%3D80%26amp%3Bdefault%3Dhttp%3A%2F%2Fwww.setupswarm.com%2Fwp-content%2Fplugins%2Fravatar%2Fcache%2F9698b3c319a46d145.png"></li></ul>
Upvotes: 1
Views: 300
Reputation: 82734
In this case, there is no need for regular expressions:
$('img[src^="http://www.gravatar.com/avatar.php"]').hide()
(using the Attribute Starts With Selector). For more complex queries use filter with a function as argument. In this function try to figure out, if the image should be hidden or not:
$('img').filter(function() {
if ($(this).attr('href').search(/http:\/\/www\.gravatar\.com/) > -1) {
return true;
}
return false;
});
Upvotes: 1