♦ jQuery Toggle
♣ Example3: jQuery Toggle
HTML elements can be toggled between showing and hiding.Below is the representation of jQuery Toggle Syntax.
Basic Syntax
$("demo").toggle(speed, callback);
speed: defining speed of toggling. Values can be slow,fast or milliseconds.
callback: function call after the completion of toggling.
In this example, .callback: function call after the completion of toggling.
Example
Input:
xxxxxxxxxx
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<title></title>
5
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
6
7
8
</head>
9
<body>
10
11
<p >Keep Clicking Me!!</p>
12
<div>Yo Folks!!</div>
13
14
15
16
</body>
17
<script type="text/javascript">
18
19
$("p").click(function(){
20
$("div").toggle();
21
});
22
23
24
</script>
25
</html>
26
Output: