views:

312

answers:

4
$(".box :text").tooltip({
//do stuff
}

now it works well for selecting :text areas under box classes however I also want to include :password areas aswell. How can I combine selectors without writing 2 seperate selectors and execute 2 different methods?

+2  A: 

You'll want a combination CSS selector:

$(".box :text, .box :password").tooltip({
        // do stuff
});
mjaz
+9  A: 

You can specify multiple selectors by comma-separating them:

$(".box :text, .box :password").tooltip({ ...

See here for documentation.

M4N
+2  A: 

for example

$(".box :text, .box :select").tooltip({});

should work for the same method. On your "execute 2 different methods"-part can you clarify the question?

Marcus
+4  A: 

Besides the already mentioned solutions:

$(".box").find(":text, :password")
Gumbo