![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
When toggling an element on and off by setting its display property via DOM access, display:none is valid for all kinds of elements, but I can't find anything about a generic value for toggling on again. There is no such value, nor is one needed. I assume I understand why there is none needed - by knowing the element type the default display value is known, too (under ideal circumstances, though). |
#12
| |||
| |||
|
|
object.style.display = 'none'; // off object.style.display = ''; // default or class-definition '' did not work in FF (so I did not even try it in IE...). |
#13
| |||
| |||
|
|
I assume I understand why there is none needed - by knowing the element type the default display value is known, too (under ideal circumstances, though). Under all circumstances. If you can produce a use case where the element cannot reasonably be determined then you may have an argument for a 'normal' value feature request for the display property. |
#14
| |||
| |||
|
Then you make something /wrong/. ![]() It works perfectly as seen in http://www.paradice-insight.us/tests/display.html |
#15
| |||
| |||
|
|
The last example, where the element is hidden using only the DOM, is much preferred (with added feature detection) as it doesn't have the potential for rendering a document unusable where scripting support is insufficient or unavailable. |
#16
| |||
| |||
|
|
When toggling an element on and off by setting its display property via DOM access, display:none is valid for all kinds of elements, but I can't find anything about a generic value for toggling on again. The time-honored approach for restoring the previous value when you don't know what it is at programming time: save it first, before setting the new value. var oldDisplay = el.style.display; el.style.display = "none"; // later ... el.style.display = oldDisplay; |
![]() |
| Thread Tools | |
| Display Modes | |
| |