Home
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"> </script> <script> $(document).ready(function () { var mouseHandler = function() { alert('The mouse entered' ); }; $('#myDiv').on('mouseenter', mouseHandler); }); </script> </head> <body> <h1> Demo: Named function as event handler </h1> <div id="myDiv" style="width:100px;height:100px;background-color:red;"> </div> </body> </html>
Result: