All user actions that a web page can respond to are called events.
An event represents the precise moment when something happens.
Examples:
- moving a mouse over an element
- selecting a radio button
- clicking on an element
Here I'm giving an example of events in Jquery.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<input type="button" value="click()" id="click"> <input type="button" value="dblclick()" id="dblclick"> <input type="button" value="mouseover()" id="mouseover"> <input type="button" value="mouseout()" id="mouseout"> <p>Hi Baby</p> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script> $("#click").click(function(){ alert('Click event'); }); $("#dblclick").dblclick(function(){ alert('dblclick event'); }); $("#mouseover").mouseover(function(){ alert('mouseover event'); }); $("#mouseout").mouseout(function(){ alert('mouseout event'); }); $(document).ready(function(){ $("p").on({ mouseenter: function(){ $(this).css("background-color", "lightgray"); }, mouseleave: function(){ $(this).css("background-color", "lightblue"); }, click: function(){ $(this).css("background-color", "yellow"); } }); }); </script> |