0

I tried to use jQuery in a template (app\code\Black\Newsletter2Go\view\frontend\templates\account\dashboard\info.phtml) but I get jQuery is not defined.

Does Magento 2 not use jQuery?

Do I have to add:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

to the head template?

1 Answer 1

2

No need to add jquery in head, You can add like below method in phtml

<script>
    require([
        'jquery'
    ],function($) {
         $(document).ready(function() {
            /* Your logic */
         });  
     });
</script>
1
  • But this does use jquery 1
    – Black
    Commented Mar 30, 2021 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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