jQuery which is a JavaScript library makes tasks like animation, event handling, or Ajax very easy. These are some tasks that would usually take multiple lines of code to be achieved, but jQuery provides certain methods that can fulfill these tasks in just a single line of code. Although, there are numerous amount of jQuery methods, however, in this guide we will stick to the jQuery hide() method and see how it works.

jQuery hide() Method

As the name suggests, the jQuery hide() method is used for the purpose of hiding specified elements. The elements that you hide using the jQuery hide() method will be completely invisible to the user.

Syntax

$selector.hide(parameter)

The different parameters that you can pass to the hide() method are as follows.

Parameter Description
speed This parameter describes the speed of the hide effects. It can exhibit values such as slow, fast, and miliseconds.
easing This parameter describes the speed of an element at different animation points. It can exhibit values such as swing, and linear.
callback It is a function that executes once the hide() method finishes.

Note: All of the above-mentioned parameters are optional.

Below we have illustrated some examples that will help establish a better understanding of the hide() method.

Example 1

This example demonstrates the hide() method by passing no parameter.

HTML

<h1>Click on the button below to hide this heading.</h1>

<button class=“button1”>Hide</button>

In the above HTML code two elements are being created

and

About the author

<img data-del="avatar" data-lazy-src="https://kirelos.com/wp-content/uploads/2022/03/echo/B49B6FDCE1F74B3598C4C9BF564AEBEC-150×150.jpg621ecdd33373a.jpg" height="112" src="data:image/svg xml,” width=”112″>

Naima Aftab

I am a software engineering professional with a profound interest in writing. I am pursuing technical writing as my full-time career and sharing my knowledge through my words.