Javascript examples for jQuery Method and Property:on
Attach multiple event handlers to a <p> element with on()
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").on({/*from www . j a va 2 s. co m*/ mouseenter: function(){ $(this).css("background-color", "lightgray"); }, mouseleave: function(){ $(this).css("background-color", "red"); }, click: function(){ $(this).css("background-color", "yellow"); } }); }); </script> </head> <body> <p>Click or move the mouse pointer over this paragraph.</p> </body> </html>