Jquery click() method

The  "click" event occurs when an element is clicked. The click() method triggers the click event or attaches a function to run when a click event occurs.

Syntax:


$(selector).click()


Example:-

<!DOCTYPE html>
<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script>
$(document).ready(function(){
    $("p").click(function(){
        alert("The paragraph was clicked.");
    });
});
  </script>
</head>
<body>

  <p>Click on this text to see the magic of click().</p>

</body>
</html>