views:

65

answers:

1

Can I select two elements with Jquery at the one time?

For example I tried this but it only selected the first element:

$('.loginStaff' || '.loginClient').click(function(){
 $('.login_form').toggle();
});

I also tried but this only selected the last element:

$('.loginStaff' && '.loginClient').click(function(){
 $('.login_form').toggle();
});

Thanks!!! Global

+5  A: 

Just use a comma to separate your selectors and it will match the combined results of all:

$('.loginStaff,.loginClient').click(function(){
  //..
});

More info:

CMS