Explanation
In my coding practice, I have implemented a script that hides certain elements if the user lacks the necessary permission to interact with them. To achieve this, I utilize the CSS property display: none
.
However, when it comes time to reveal these hidden elements, I face the dilemma of restoring their display value without assuming it was originally set to block
. Is there a method to reset the display property or assign it a generic value?
Example
For instance, consider the element
<div class="fancy-class">...</div>
. If the class fancy-class
is styled as inline-block
, changing it abruptly to block
within my script could disrupt the user interface.
Efforts
I have experimented with utilizing display: initial
; however, this action merely reverts the styling to the default settings specified for HTML elements rather than capturing the original class-specific styles.
Resorting to storing and reapplying the original values in an array seems cumbersome and inelegant.