jQuery Events
How to create Events in jQuery

When user do some action like click on button, click on checkbox, mouse hover etc is part of event.

some common event are:
click
load
submit
change
focus
keypress

and many more

suppose we want to hide all paragraph so the code is
$("p").hide();

Example1 by Download jQuery

<html>
<head>
<script src="jquery-3.2.1.min.js"/></script>
<script>
$(document).ready(function()
{
$("h2").click(function(){
$(this).hide();
});
}
);
</script>
</head>
<body>
<h2>this is h2</h2>
</body>
</html>

Example2 by Using Google CDN

<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"/></script>
<script>
$(document).ready(function()
{
$("h2").click(function(){
$(this).hide();
});
}
);
</script>
</head>
<body>
<h2>this is h2</h2>
</body>
</html>


Previous
Next