Difference between jQuery .hide() and .css(“display”, “none”)

后端 未结 7 1105
既然无缘
既然无缘 2020-12-12 14:33

Is there any difference between

jQuery(\'#id\').show() and jQuery(\'#id\').css(\"display\",\"block\")

and

jQuery(\'#id\').         


        
7条回答
  •  一生所求
    2020-12-12 15:09

    no difference

    With no parameters, the .hide() method is the simplest way to hide an element:

    $('.target').hide(); The matched elements will be hidden immediately, with no animation. This is roughly equivalent to calling .css('display', 'none'), except that the value of the display property is saved in jQuery's data cache so that display can later be restored to its initial value. If an element has a display value of inline, then is hidden and shown, it will once again be displayed inline.

    Same about show

提交回复
热议问题