Edoras
Edoras

Reputation: 329

Find links with image format at the end of address link (such as jpg, png, gif, etc.)

I need this code to take a different size letters - image format such as "jpg and JPG, gif and GIF" etc. Also not to take it, for example, not where ".jpg" at the end of the link, to it for nothing as "jpg.html". It is also possible to add that the exemption did not want to look for domain "imageshack"?

    $(document).ready(function() {
        $('a.postlink').filter(function() {
            return $(this).attr('href').match(/\.(jpg|png|gif|jpeg)/);
        }).addClass('lightview');
    });

Thanks and sorry for my English.

Upvotes: 0

Views: 190

Answers (1)

ShankarSangoli
ShankarSangoli

Reputation: 69915

Try this

$(document).ready(function() {
    $('a.postlink').filter(function() {
        return $(this).attr('href').match(/\.(jpe?g|png|gif)/i);
    }).addClass('lightview');
});

Upvotes: 1

Related Questions