jQuery('#id').css("display","block")
The display
property can have many possible values, among which are block
, inline
, inline-block
, and many more.
The .show()
method doesn't set it necessarily to block
, 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 display
property 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).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…