jQuery selector not working for
Zeni last edited by Zeni
Trying to close ‘Spliter side’ with button click.
<ons-splitter-side id="menu" side="left" width="120px" animation='push' collapse swipeable>
var menu = document.getElementById('menu'); menu.close();
This does not work:
I get error "Uncaught TypeError: menu.close is not a function"
Other jquery commands are working.
What could be the reason?
closeis a method of the element itself, not of the jQuery wrapper. Try
Zeni last edited by
Thanks Fran, it solved my problem. You are Guru!!.
larabrian last edited by
Uncaught TypeError is usually caused because scripts are loaded in the wrong order . The browser will execute the scripts in the order it finds them. If in a script you attempt to access an element that hasn’t been reached yet then you will get an error. Make sure that you don’t have a script above one that it requires.
Sometimes this warning may also be shown if jQuery is declared more than once in your code. The second jQuery declaration prevents bootstrap.js from working correctly. The problem is due to having jQuery instances more than one time. Take care if you are using many files with multiples instance of jQuery. Just leave one instance of jQuery and your code will work.