KSPR
KSPR

Reputation: 2375

TypeError: $(...).mmenu is not a function

I use the jquery.mmenu plugin as a hamburger menu:

import $ from 'jquery';
import 'jquery.mmenu';

$(document).ready(function () {
  $('#mobileMenu').mmenu();
});

This works. But I have included jquery already trough a cdn:

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

So if I remove: import $ from 'jquery';. I get:

TypeError: $(...).mmenu is not a function

How do I have to write this in order to not include jquery twice?

Upvotes: 0

Views: 2857

Answers (1)

Abdullah Tahan
Abdullah Tahan

Reputation: 2129

Just add jquery in top of the libraries

<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    
<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery.mmenu/6.1.0/jquery.mmenu.all.js"></script>

Upvotes: 2

Related Questions