Javascript Ajax jQuery Html PHP Example Quiz New MORE

jQuery click() Method

jQuery click event occurs when you click on an html element. It can be a button, span, div, hyperlink and paragraph.

It is an inbuilt function of jQuery.

jQuery click() Method Syntax
$(selector).click(function(){
//block of code that runs when the click event triggers
});

Example:

	<!DOCTYPE html>
	<html>
	<head>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	<script>
	$(document).ready(function(){
	  $("button").dblclick(function(){
		alert("The button was Clicked.");
	  });
	});
	</script>
	</head>
	<body>

	<button>Click on this Button.</button>
	</body>
	</html>
Run it Yourself »