开发者

jQuery: caseless selector search?

开发者 https://www.devze.com 2023-03-04 23:04 出处:网络
For example searching $(\'[name=whatever]\') 开发者_开发技巧 should find $(\'[name=whatever]\') and$(\'[name=WhaTevEr]\')

For example searching

$('[name=whatever]')
开发者_开发技巧

should find

 $('[name=whatever]') and  $('[name=WhaTevEr]')

Thanks ;)


Any possible solution is going to be really inefficient, because it cannot work with the browser's native selector engine. It would be better to use a class to identify the elements.

However, if you're insistent on this approach, you can use filter():

$('[name]').filter(function () {
    return this.name.toLowerCase() == "whatever";
});


Not directly, but you can have a regex as selector

Take a look at this topic:

jQuery selector regular expressions

0

精彩评论

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