Define hide() method of jQuery in detail.

The jQuery hide() method hides the specified HTML elements like DIV, paragraphs or other elements. The hide jQuery method 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 jQuery hide()

Following is the syntax of hide method:
$(selector).hide(speed,callback)
Where
The Selector can be an element like div, p, etc. in hide method.
Speed = This is an optional parameter with the following possible values:
“slow”
“fast”
Or value in milliseconds
Callback = after hide() method is completed, an optional callback function to perform certain action.

An example of hide() method

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

<!DOCTYPE html>

<head>
<title>jQuery Testing</title>
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
   <script type="text/javascript" language="javascript">
   $(document).ready(function() {
     $(".hidetext").click(function () {
     $(".text").hide("slow");
    });
   });
   </script>
</head>
<body>
   <button class="hidetext">Hide yellow line</button>
   <div class="text" style="background-color:yellow;">
     This is Yellow line!!
   </div>
</body>
</html>
<!DOCTYPE html>
<head>
<title>jQuery Testing</title>
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" language="javascript">
    $(document).ready(function() {
      $(".hidetext").click(function () {
      $(".text").hide("slow");
     });
    });
    </script>
<button class="hidetext">Hide yellow line</button>
<div class="text" style="background-color:yellow;">
This is Yellow line!!
</div>
</body>
</html>

</head>

<body>


Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*