Home >>jQuery Tutorial >jQuery hide() Method
jQuery hide() method in jQuery is an inbuilt method to hide the selected elements.
Syntax:$(selector).hide(speed,easing,callback)
Parameter | Description |
---|---|
speed | It is an optional parameter and is used to Specify the speed of the hide effect. Its default value is 400 milliseconds
Possible values:
|
easing | It is an optional parameter and is Specify the speed of the element in points of the animation. Its Default value is "swing"
Possible values:
|
callback | It is an optional parameter. After the hide() method is completed a function to be executed |
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".btn1").click(function(){
$("#hide").hide();
});
$(".btn2").click(function(){
$("#hide").show();
});
});
</script>
</head>
<body>
<h3 id="hide">PHPTPOINT</h3>
<button class="btn1">Hide</button>
<button class="btn2">Show</button>
</body>
</html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
<!-- jQuery code to show the working of this method -->
<script>
$(document).ready(function() {
$(".btn3").click(function() {
$("#heading1").hide();
});
});
</script>
<style>
#heading {
width: 50%;
height: 80px;
padding: 20px;
margin: 10px;
border: 2px solid orange;
font-size: 30px;
}
.btn3 {
margin: 10px;
}
</style>
</head>
<body>
<div id="heading">
<p id="heading1">PHPTPOINT !.</p>
</div>
<!-- click on this button and above paragraph will disappear -->
<button class="btn3">Click me !</button>
</body>
</html>
PHPTPOINT !.