JavaScript element.hidden Property
You are Here:
JavaScript element.hidden Property
The element.hidden
property gets or sets the hidden status of the specified element.
Tips: The hidden property applies to all presentation modes and should not be used to hide content that is meant to be directly accessible to the user.
Get Hidden Status
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<p hidden>This paragarph is hidden</p>
<button onclick="myFunction()">Click Me</button>
<p id="point"></p>
<script>
var x = document.getElementById("point");
var elem = document.getElementsByTagName("p")[0];
function myFunction(){
x.innerHTML = elem.hidden;
}
</script>
</body>
</html>
Syntax
element.hidden
Return Values
Value | Explanation |
---|---|
true | If the specified element is hidden. |
false | If the specified element is NOT hidden. |
Set Hidden Status
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<p>Click on the button to hide this paragarph.</p>
<button onclick="myFunction()">Click Me</button>
<script>
var elem = document.getElementsByTagName("p")[0];
function myFunction(){
elem.hidden = true;
}
</script>
</body>
</html>
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.