What .on() in Jquery do?

The on() method attaches one or more event handlers for the selected elements.

For better understanding follow the below code.

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("#d1").on({
    mouseenter: function(){
      $(this).css("background-color", "orange");
    },  
    mouseleave: function(){
      $(this).css("background-color", "yellow");
    }, 
    click: function(){
      $(this).css("background-color", "skyblue");
    }  
  });
});
</script>
</head>
<body>

<div id="d1">Click or move the mouse pointer over this paragraph.</div>

</body>
</html>

What .on() in Jquery do?expoundsofttechsolution

Magento 2 checks if the product has a special price