Events in JavaScript
Events play an important role in any business application where you want to save a record on a button-click event, or show some message, or change some element's background color. Any of these events can be defined from the control level itself or register directly through the script.
Let's have a look at this example, which changes the inner html
code of the div
control when the mouse is entered:
<html> <body> <div id="contentPane" style="width:200px; height:200px;"> </div> <script> var divPane = document.getElementById("contentPane"); divPane.onmouseenter = function () { divPane.innerHTML = "You are inside the div"; }; divPane.onmouseleave = function () { divPane.innerHTML = "You are outside the div"; }; </script> </body> </html>
The preceding example registered two events on the script side for...