visibility Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:visibility

Description

The visibility property sets or gets whether an element should be visible.

Property Values

ValueDescription
visible Visible. This is default
hidden Not visible, but occupy the space
collapse used on a table row or cell
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: visible?
Return Value: A String, representing whether the content of an element is displayed or not
CSS VersionCSS2

Hide the content of a <p> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" style="visibility:hidden;">This is a p element.</p>

<button type="button" onclick="myFunction()">Test</button>

<script>
function myFunction() {//from   w  w  w  . j  a  v a2 s  .  com
    document.getElementById("myP").style.visibility = 'hidden';
}
</script>

</body>
</html>

Related Tutorials