Javascript Ajax jQuery Html PHP Example Quiz New MORE

jQuery hide()


The jQuery hide() method is used to hide a perticular HTML element. It is as inbuilt function of jQuery.

Syntax:

1) $(selector).hide();
2) $(selector).hide(speed, callback);
3) $(selector).hide(speed, easing, callback);

speed: It is an optional parameter. It specifies the speed of the delay. Its possible vales are slow, fast and milliseconds.

easing: It specifies the easing function to be used for transition.

callback: It is also an optional parameter. It specifies the function to be called after completion of hide() effect.

Example

<!DOCTYPE html>  
<html lang="en">  
<head>  
  <meta charset="utf-8">  
  <title>hide() jQuery Method</title>  
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <style>  
  	h2 {  
    	color: white;  
        text-align:center;
        padding-top:40px;
  	}  
  </style>  
<script type="text/javascript">
$(document).ready(function(){
  $("#button").click(function(){
     $("#div").hide();
  });
});
</script> 
</head>  
<body>
<button id="button">Hide div</button>
<br>
<br>
<div id="div" style="width:400;height:100px;background-color:green;"><h2 style="color:white;text-align:center;padding-top:40px;">STUDENTS TUTORIAL</h2></div>
 
<p>By click on the hide button the div is hide.</p>
</body>  
</html>

Run it Yourself »