Skip to content

.defaultDisplayStyle()

hlaCk edited this page Dec 21, 2018 · 1 revision

Default CSS display for an element.

Get default css display value for element tag.

Get default display style

_z(selector).defaultDisplayStyle();

  • _z to access UnderZ library.
  • selector select element by selector to get default style. ( you can send DOM element or selector)
  • defaultDisplayStyle method/action name.

Returns: CSS Display Property String

Get default display style for element tag

_z().defaultDisplayStyle( tagname );

  • _z to access UnderZ library.
  • defaultDisplayStyle method/action name.
  • tagname Get default display style value for this tag. ( you CAN NOT send DOM element, must be HTML tagname)

Returns: CSS Display Property String

Examples

<button id="textdg" style="display: grid;">Display grid</button>
<button id="textdf" style="display: flex;">Display flex</button>
<button id="textdib" style="display: inline-block;">Display inline block</button>

<script>
// bind click event to all buttons
_z("button").click(function () { 
	alert( _z(this).defaultDisplayStyle() ); // default button css display is: inline-block
});

// get default CSS display value for div
alert( _z().defaultDisplayStyle( "div" ) ); // default button css display is: block
</script>

Recommended: bind events in .ready() to execute the event when the document is fully loaded.

Clone this wiki locally