Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using jquery $.each with multiple selectors

Tags:

jquery

I want get all the accesskeys that are on a button or link. I have the following.

$(":button[accesskey!=''], :a[accesskey!='']").each(function(i) {
 //code
});

You can see it here http://jsfiddle.net/QNPZU/

I thought you could have multiple selectors by separating them using a comma but the above code does not work.

If I do

$(":*[accesskey!='']").each(function(i) {
 //code
});

it will work, but I take it there will be a performance problem if the dom is huge?

like image 264
Decrypter Avatar asked Aug 15 '12 09:08

Decrypter


1 Answers

You can code:

$("button[accesskey], a[accesskey]").each(function(i) {
   //code
});
like image 148
undefined Avatar answered Oct 02 '22 00:10

undefined