Compare mouse click, mouse over and mouse out events - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:on

Description

Compare mouse click, mouse over and mouse out events

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").on({//w  w w  . ja v  a  2 s.c  o m
        mouseover: function(){
            $("body").css("background-color", "gray");
        },
        mouseout: function(){
            $("body").css("background-color", "blue");
        },
        click: function(){
            $("body").css("background-color", "yellow");
        }
    });
});
</script>
</head>
<body>

<p>Click or move the mouse pointer over this paragraph.</p>

</body>
</html>

Related Tutorials