2012-02-05 43 views
0

我需要這個代碼採取不同大小的字母 - 圖像格式,例如「JPGJPGGIFGIF「等 也不宜服用,例如,不要在那裏」 .JPG在鏈路結束後,將它白白爲」 jpg.html 」。 也可以補充一點,豁免不想尋找域imageshack」?查找地址鏈接的結束與圖像格式的鏈接(如JPG,PNG,GIF等)

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

感謝和抱歉我的英語。

回答

1

試試這個

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

這不工作只爲爲.jpg,.png的.jpeg和.gif – Edoras 2012-02-06 14:57:06

+0

試試我的編輯答案。 – ShankarSangoli 2012-02-06 15:00:31