trigger the mouseover event for the selected elements: - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:mouseover

Description

trigger the mouseover event for the selected elements:

Demo Code

ResultView the demo in separate window

<!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");
    });/*  w w w  . ja  v a2  s .  c o  m*/
    $("p").mouseout(function(){
        $("p").css("background-color", "lightgray");
    });
    $("#btn1").click(function(){
        $("p").mouseover();
    });
    $("#btn2").click(function(){
        $("p").mouseout();
    });
});
</script>
</head>
<body>

<p>Move the mouse pointer over this paragraph.</p>

<button id="btn1">Trigger mouseover event</button><br>
<button id="btn2">Trigger mouseout event</button>

</body>
</html>

Related Tutorials