jQuery hide | Using hide method of jQuery to hide elements – div, p etc.

What is jQuery hide() method?

The jQuery hide() method hides specified HTML elements like DIV, paragraphs or others. That can be used to make user’s experience better in order to provide them facility what to show and what to not in a website besides other uses.

Syntax of using the $.hide() method



Selector = can be an element like div, p, etc.
Speed = Optional parameter that specifies the hide speed with possible values of

  1. “slow”
  2. “fast”
  3. Or value in milliseconds

Callback = after the hide () method is completed, an optional callback function to perform a certain action can be given.

Running Example of jQuery hide() method

In this example, we will use jquery hide method to hide DIV with name “text” after clicking “Hide yellow line” button.

Just copy paste below code to a new HTML file and name it like test_hide.html or click the link below to see the online demo.

jQuery hide

Experience this example online

Example of the hide method with callback function

In this example, as you click the “Hide yellow line” button, the yellow line will disappear. After that, the callback function will execute that will display an alert:

jQuery hide callback

Experience this example online

Also see: jQuery show() method | jQuery toggle() method

Was this article helpful?

Related Articles

Leave A Comment?