Multiple selectors with jQuery

Is it possible to select two elements using jquery at a time?

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

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

I also tried, but this only selected the last item:

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

Thanks!!! Global

+3
source share
1 answer

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

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

Additional Information:

+8
source

Source: https://habr.com/ru/post/1724688/


All Articles