jQuery performance: hide() vs is(':visible') - which is faster?

后端 未结 3 467
故里飘歌
故里飘歌 2021-01-15 05:21

I have multiple dropdown boxes which drop when their link is clicked. The boxes have the possibility to overlap if they are open at the same time.

Is it faster to qu

3条回答
  •  无人共我
    2021-01-15 06:00

    You could use .toggle() function for this too.

    var $box1 = $('#box1'),
        $box2 = $('#box2');
    $('.majorDiv').on('click', '#box1-link', function(e){
    
      var $this = $(this);
      e.preventDefault();
    
      $box1.fadeToggle();
      $box2.slideDown(200, function(){
        //do stuff here
      });
    
    });
    

提交回复
热议问题