Alex Rivera | Logout

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

Asked 2010-12-09T10:06:35.093
155

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 actually doing to the HTML element?

Edit
Report

1 Answer

35

.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.

answered 2010-12-09T10:08:57.150

Your Answer