Nysa Nysa - 6 months ago 307
Javascript Question

Bootstrap $('#myModal').modal('show') is not working

I'm not sure why but all the modal functions are not working with me.
I checked the version and the load they are fine.

I keep getting this error message:

Uncaught TypeError: $(...).modal is not a function

for the hide I already found an alternative.
instead of:


I used this :

$('#myModal .close').click();

And it works perfectly.

The problem now is with the show


I also tried both




but unfortunately none of them is working.

Here html code -when the button is clicked I will do some verification and handle a json data from the web service if it succeed then I want show my modal- everything is working except the show.

<button type="button" id="creatNewAcount" class="btn btn-default" data-toggle="modal">Sign up</button>

if there's any alternative I would like to know it.


Most often reason for such problems is

1.If you have defined the jquery library more than once.

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
 <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

    <div class="modal fade" id="myModal" aria-hidden="true">

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

The bootstrap library gets applied to the first jquery library but when you reload the jquery library, the original bootstrap load is lost(Modal function is in bootstrap).

2.Please wrap your JS code inside


3.Please re check id of modal is what you are using(Also check if there is duplication of id on page).