How to use jquery in Magento 2


In order to implement custom jQuery functionalities, you need to include jQuery code inside require function like below code:

 require(['jquery', 'jquery/ui'], function($){ 
      jQuery(document).ready(function(){
         jQuery("#mybtn").click(function(){
            alert("This is syntax for jquery in magento 2");
         });
         //Your Custom Code
      });

 });

No comments:

Post a Comment

Buy/Sell Source Code of Website,Apps,Softwares

Install sample data in magento 2