Javascript examples for jQuery Method and Property:mouseover
The mouseover() method triggers the mouseover event, or sets function as mouseover event handler.
$(selector).mouseover(function);
Parameter | Require | Description |
---|---|---|
function | Optional. | function to run when the mouseover event is triggered |
The following code shows how to set the background color to yellow, when the mouse pointer is over a <p> element:
<!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").mouseover(function(){ $("p").css("background-color", "yellow"); });/*from w ww.ja v a 2s . c o m*/ $("p").mouseout(function(){ $("p").css("background-color", "lightgray"); }); }); </script> </head> <body> <p>Move the mouse pointer over this paragraph.</p> </body> </html>