The click() is an inbuilt method in jQuery that triggers the click event or attach a function to run when a click event occurs.

Syntax:

$(selector).click() -Trigger the click event for the selected elements.

$(selector).click(function) -Attach a function to the click event.

Example:

<!doctype html>
	<html lang="en">
		<head>
			<meta charset="utf-8">
			<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
			<script>  
				$(document).ready(function(){  
				    $("p").click(function(){  
						alert("This paragraph was clicked.");  
				    });  
				});  
			</script>   
		</head>
		<body>
			<p>Click Me.</p>  
		</body>
	</html>

In this example function is optional. It specifies the function to run when the click event occurs.