How to use Hide Method in JQuery

This article describe about jQuary Hide Button and Paragraph Method.
  • 2148

Hide button in jQuery

$(this).hide() method

hide() method is use to hide a button.

$(this).hide() is use hiding current HTML element above this page.

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $("button").click(function () {

            $(this).hide();

        });

    });

</script>

</head>

 

<body>

<button>Click here</button>

</body>

</html>

 

Output

op1.jpg

 

click this button, then hide the button above this page .

 

Hide paragraph in jQuery

$("p").hide() method

hide() method is hide a paragraph.

$("p").hide() method hiding all<p> elements in jQuery.

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $("button").click(function () {

            $("p").hide();

        });

    });

</script>

</head>

 

<body>

<h2>This is a jQuery</h2>

<p>This is a text.</p>

<button>Click here</button>

</body>

</html>

 

Output

 

 op2.jpg

After click button

 op3.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.