EN
                                
                            
                        jQuery - mouse click event
                                    9
                                    points
                                
                                In this article, we would like to show you how to create a click event using jQuery. The function works similarly to the onclick event.
1. click method example
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
</head>
<body>
  <button id="button">Click me!</button>
  <script>
    $(document).ready(function() {
		var button = $('#button');
      
      	button.click(function() {
        	button.text('Button clicked!');
        });
    });
  </script>
</body>
</html>
2. on method with event name example
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
</head>
<body>
  <button id="button">Click me!</button>
  <script>
    $(document).ready(function() {
		var button = $('#button');
      
      	button.on('click', function() {
        	button.text('Button clicked!');
        });
    });
  </script>
</body>
</html>
3. on method with event object example
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
</head>
<body>
  <button id="button">Click me!</button>
  <script>
    $(document).ready(function() {
		var button = $('#button');
      
      	button.on({
            'click': function() {
        	    button.text('Button clicked!');
            }
        });
    });
  </script>
</body>
</html>