Difference between jQuery’s .hide() and setting CSS to display: none

后端 未结 7 1623
天涯浪人
天涯浪人 2020-11-30 23:19

Which am I better off doing? .hide() is quicker than writing out .css(\"display\", \"none\"), but what’s the difference and what are both of them a

7条回答
  •  一整个雨季
    2020-11-30 23:52

    .hide() stores the previous display property just before setting it to none, so if it wasn't the standard display property for the element you're a bit safer, .show() will use that stored property as what to go back to. So...it does some extra work, but unless you're doing tons of elements, the speed difference should be negligible.

提交回复
热议问题