Bootstrap dropdown Jquery Uncaught Error: Syntax error, unrecognized expression
If you are stuck on old Bootstrap then you can patch getParent
function of bootstrap-dropdown.js
.
Just replace $parent = selector && $(selector)
with this:
if (selector && selector !== '#') {
$parent = $(selector)
}
In my case, I had a script that automatically switches the "active" class on menu items on scroll, all the 'href' of the 'a' html tags under the Boostrap menu must not equal to "#", this solution worked for my case, if anyone has a similar case.
The issue has been fixed by following these steps:
- Use latest version of jQuery v2.1.3 and bootstrap v3.3.6
- Load Bootstrap JS after jquery in order
- Using data-target="#" with href="#" and put the external link on an onClick() trigger.
Hope it helps.