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>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    mouseenter: function(){
      $(this).css("background-color", "orange");
    mouseleave: function(){
      $(this).css("background-color", "yellow");
    click: function(){
      $(this).css("background-color", "skyblue");

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


What .on() in Jquery do?expoundsofttechsolution

Magento 2 checks if the product has a special price