This method is used to show() and hide the content of selected elements. show() method is execute when selected element content is hide while hide() method is execute when selected element content is visible.
The toggle() method toggles between hide() and show() for the selected elements.
Note : Toggle method is work in between hide() and show() method.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").toggle();
});
});
</script>
</head>
<body>
<p>This is a First paragraph.</p>
<button>Toggle</button>
</body>
</html>
Output :When you click on the button ,if message is visible then on clicking the button that message will be hide and vice versa.
0 Comment(s)