jQuery on() with event map

Description

jQuery on() with event map

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>//from w w  w .  j a va2 s .co m
<script>
$(document).ready(function(){
  $("p").on({
    mouseover: function(){
      $("body").css("background-color", "lightgray");
    },
    mouseout: function(){
      $("body").css("background-color", "red");
    },
    click: function(){
      $("body").css("background-color", "yellow");
    }
  });
});
</script>
</head>
<body>

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

</body>
</html>



PreviousNext

Related