Home  >  jQuery

Example of .click() in jQuery

April 28, 2013
In jQuery, .click() is applied on an event handler. .click() triggers that event. .click() is equivalent to java script click function. We use it as
$("h6").click(function () {})
 
So here on click of any <h6></h6> , the given function will execute. Find the example.

<!DOCTYPE html>
<html>
<head>
<style>
h6 { color:blue; cursor:pointer;}
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<h6>Click on First Heading</h6>
<h6>Click on Second Heading</h6>
<h6>Click on Third Heading</h6>
<script>
$("h6").click(function () {
$(this).css("color","red");
});
</script>
</body>
</html>
 

Output
FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us