开发者

How to do Case insensitive selection in jQuery?

I wanted to select all tags which points to an swf in jQuery. I wrote the following code and whi开发者_开发技巧ch works fine

$(a[href$=".swf"]).each( function(){
   alert('hello');
});

Now if i want to include SWF also for search, what is the best way?


You may take a look at the filter function.

$('a').filter(function() {
    return (/\.swf$/i).test($(this).attr('href'));
}).each(function() {
    alert('hello');
});


For such a basic case, why not just do something like:

$('a[href$=".swf"], a[href$=".SWF"]').each( function(){
   alert('hello');
});

In general though, Darin has pointed you in the right direction.


If you are interested in .swf and .SWF, you can use this:

$('a[href$=".swf"], a[href$=".SWF"]').each( function(){
   alert('hello');
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜