The hidden Attribute
The hidden attribute is a boolean attribute. It can hide an element.
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
<script>
var toggleHidden = function() {
var elem = document.getElementById("toggle");
if (elem.hasAttribute("hidden")) {
elem.removeAttribute("hidden");
} else {
elem.setAttribute("hidden", "hidden");
}
}
</script>
</head>
<body>
<button onclick="toggleHidden()">Toggle</button>
<table>
<tr>
<th>Name</th>
<th>City</th>
</tr>
<tr>
<td>James Bond</td>
<td>London</td>
</tr>
<tr id="toggle" hidden>
<td>Joe Smith</td>
<td>New York</td>
</tr>
<tr>
<td>Boud Jones</td>
<td>Paris</td>
</tr>
</table>
</body>
</html>
Home
HTML CSS Book
HTML
HTML CSS Book
HTML
HTML5 Global Attributes:
- The accesskey Attribute
- The class Attribute
- The contenteditable Attribute
- The contextmenu Attribute
- The dir Attribute
- The draggable Attribute
- The dropzone Attribute
- The hidden Attribute
- The id Attribute
- The lang Attribute
- The spellcheck Attribute
- The style Attribute
- The tabindex Attribute
- The title Attribute
Related: