THE WORLD'S LARGEST WEB DEVELOPER SITE

W3.JS Hide

Hiding HTML elements

w3.hide(selector)

Hiding Elements Using Element Id

To hide an element with a specified id, use a hash tag (#) in front of the id name.

Hide an element with id="London":

Example

<button onclick="w3.hide('#London')">Hide</button>

Try It Yourself »


Hiding Elements Using Tag Name

To hide all elements with a specified tag name, use the tag name (without < and >) as the selector.

Hide all <h2> elements:

Example

<button onclick="w3.hide('h2')">Hide</button>

Try It Yourself »


Hiding Elements Using Class Name

To hide all elements with a specified class name, use a period (.) in front of the class name.

Hide elements with class="city":

Example

<button onclick="w3.hide('.city')">Hide</button>

Try It Yourself »