<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Executing a Function on Mouseenter Event in jQuery</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <style> p{ padding: 15px; font: 21px sans-serif; background: Purple; } p.highlight{ background: skyblue; } </style> <script> $(document).ready(function(){ $("p").mouseenter(function(){ $(this).addClass("highlight"); }); $("p").mouseleave(function(){ $(this).removeClass("highlight"); }); }); </script> </head> <body> <p>Mouse Hover Me</p> <p>Mouse Hover Me</p> </body> </html>