0

I am trying to use JQuery in my block functions, but I get an error saying JQuery not found. I tried google and some suggested to add it to local.xml but I think Magento2 does not have local.xml.

Can anyone help me on how to enable JQuery in Magento2?

Thanks

0

You should use requirejs to manage/resolve dependencies in JS code. For example

require(
  ['jquery'], // list of dependencies
  function($) {
     //put your code that use jquery here
  } 
) 

See documentation for more detais

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.