JS/Jquery, Match not finding the PNG = match('/gif|jpg|jpeg|png/')

Posted by nobosh on Stack Overflow See other posts from Stack Overflow or by nobosh
Published on 2010-04-04T19:52:44Z Indexed on 2010/04/04 20:03 UTC
Read the original article Hit count: 529

Filed under:
|
|
|

I have the following code which I use to match fancybox possible elements:

$('a.grouped_elements').each(function(){
    var elem = $(this);
    // Convert everything to lower case to match smart
    if(elem.attr('href').toLowerCase().match('/gif|jpg|jpeg|png/') != null) {
        elem.fancybox();
    }
});

It works great with JPGs but it isn't matching PNGs for some reason. Anyone see a bug with the code? Thanks

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript