开发者

jquery "or" statement

开发者 https://www.devze.com 2023-01-10 19:22 出处:网络
How do i use an \"or\" statement in jquery, i have two separate statements that i think i can combine to be just one:

How do i use an "or" statement in jquery, i have two separate statements that i think i can combine to be just one:

$('li.members').hover(function() {
    $('.members-show').show();
    $('.brokers-show').hide();
    $('.providers-show').hide();
    $('.employers-show').hide();
    $('.seniors-show').hide();
    return false;
  });

$('li.members-active').hover(function() {开发者_StackOverflow社区
    $('.members-show').show();
    $('.brokers-show').hide();
    $('.providers-show').hide();
    $('.employers-show').hide();
    $('.seniors-show').hide();
    return false;
  });


$('li.members, li.members-active').hover(function() {
    $('.members-show').show();
    $('.brokers-show').hide();
    $('.providers-show').hide();
    $('.employers-show').hide();
    $('.seniors-show').hide();
    return false;
  });


$('li.members, li.members-active').hover(function() {
    $('.members-show').show();
    $('.members-show, .providers-show, .employers-show, .seniors-show').hide();    
    return false;
  });


I think you can use Multiple Selector


Try the Multiple Selector:

$('li.members,li.members-active').hover(function() {
    $('.members-show').show();
    $('.brokers-show').hide();
    $('.providers-show').hide();
    $('.employers-show').hide();
    $('.seniors-show').hide();
    return false;
  });
0

精彩评论

暂无评论...
验证码 换一张
取 消