Is there any difference between
jQuery('#id').show() and jQuery('#id').css("display","block")
and
jQuery('#id').hide() and jQuery('#id').css("display","none")
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
displayproperty can have many possible values, among which areblock,inline,inline-block, and many more.The
.show()method doesn’t set it necessarily toblock, but rather resets it to what you defined it (if at all).In the jQuery source code, you can see how they’re setting the
displayproperty to “” (an empty string) to check what it was before any jQuery manipulation: little link.On the other hand, hiding is done via
display: none;, so you can consider.hide()and.css("display", "none")equivalent to some point.It’s recommended to use
.show()and.hide()anyway to avoid any gotcha’s (plus, they’re shorter).