jQuery hide()
The jQuery hide() method is used to conceal the selected elements.
Syntax
$(selector).hide(speed, callback);
- selector: Specifies the element(s) to hide.
- speed (optional): Defines the duration of the hide animation (e.g., slow, fast, or milliseconds).
- callback (optional): A function to execute after the hide animation is complete.
<!DOCTYPE html>
<html>
<head>
<title>jQuery hide() Example</title>
<script>
$(document).ready(function(){
$("#hideButton").click(function(){
$("#text").hide("slow", function(){
alert("The text has been
hidden.");
});
});
});
</script>
</head>
<body>
<p id="text">This is some text that will be hidden.</p>
<button id="hideButton">Hide Text</button>
</body>
</html>