On Jan 17, 2009, at 3:52 PM, Mike Alsup wrote:


I use a light-box plugin on my website,http://www.FreeSoftwareWorkshop.com
and I need to select the links that end in .png, .jpg or .gif.
This is how I use the selector (it works only for .png):

$(function(){
        $(".post a[href$=.png]").lightBox({

});
});

How can modify the above in order to select all the links that point
to images (png,jpg,gif)?


$(".post a[href$=.png],.post a[href$=.jpg],.post a[href$=.gif]");

A bit verbose, but still one line. :-)


Or, one other way, for the sake of variety:

$('.post a').filter(function() {
  return /(.png|.jpg|.gif)$/.test(this.href);
});

--Karl
____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com

Reply via email to