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

后端 未结 7 1139
既然无缘
既然无缘 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:13

    Yes there is a difference.

    jQuery('#id').css("display","block") will always set the element you want to show as block.

    jQuery('#id').show() will et is to what display type it initially was, display: inline for example.

    See Jquery Doc

提交回复
热议问题