on Method Event in JQuery | Tryit Editor for Web Development
Edit This Code:
See Result »
<html> <body> <h1>Welcome To T4-Tutorials</h1> <h2>The on Method Event:</h2> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").on({ mouseenter: function(){ $(this).css("background-color", "yellow"); }, mouseleave: function(){ $(this).css("background-color", "red"); }, click: function(){ $(this).css("background-color", "lightgray"); } }); }); </script> </head> <body> <p>Click me: Thanks For Your Love For T4-Tutorials</p> </body> </html>
Result: