Events
All the user actions on a HTML page to which the page can respond is called an Event.
There are several events that are supported by jQuery.
Some common DOM events are:
- click
- dbclick
- mouseenter
- mouseleave
- hover
- mouseup
- mousedown
- keypress
- keyup
- keydown
- submit
- blur
- change
- focus
- reload
- resize
- unload
- scroll
In this example hide() and show() functions are used to hide a <p> element using two buttons one having id=hide and other id=show. When you click the hide button the line hides.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("#hide").click(function(){
$("p").hide();
});
$("#show").click(function(){
$("p").show();
});
});
</script>
</head>
<body>
<p>If you click on the "Hide" button, I will disappear.</p>
<button id="hide">Hide</button>
<button id="show">Show</button>
</body>
</html>
No comments:
Post a Comment