x
 
1
<!DOCTYPE html>
2
<title>My Example</title>
3
4
<style>
5
  p {
6
    background: gold;
7
    padding: 20px;
8
  }
9
</style>
10
11
<!-- Load jQuery -->
12
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
13
14
<!-- Use jQuery -->
15
<script>
16
// Wait for DOM to load and be ready
17
$(document).ready(function(){
18
  
19
  // Click event handler for the 'toggle' button
20
  $( "#toggleContent" ).click(function() {
21
  
22
    // Toggle the element
23
    $( "p" ).fadeToggle( "slow" );
24
    
25
  });
26
27
});
28
</script>
29
<button id="toggleContent">Toggle</button>
30
<p>Toggle me!</p>