Somebody
Somebody

Reputation: 9645

jQuery: caseless selector search?

For example searching

$('[name=whatever]')

should find

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

Thanks ;)

Upvotes: 1

Views: 101

Answers (2)

Ortiga
Ortiga

Reputation: 8824

Not directly, but you can have a regex as selector

Take a look at this topic:

jQuery selector regular expressions

Upvotes: 0

Andy E
Andy E

Reputation: 344713

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";
});

Upvotes: 6

Related Questions