I have a function in my jQuery for my wordpress site. It's in my main.js and above document.ready and my main.js is being loaded after jQuery loads.
Everything works in my static version of the site, it doesn't work when I try to implement it in my theme in wordpress
The function:
function toggleChevron(e) {
$(e.target)
.prev('.panel-heading')
.find("i.indicator")
.toggleClass('glyphicon-triangle-bottom glyphicon-triangle-left');
}
$('#accordion').on('hidden.bs.collapse', toggleChevron);
$('#accordion').on('shown.bs.collapse', toggleChevron);
It gives this error in my console:
Uncaught TypeError: $ is not a function`
When I try to replace the $ with jQuery I get no errors in my console but it doesn't work. Anyone knows what's going on here?
Thanks in advance!
.on()calls before the element with id "accordion" is in the DOM, you'll get no errors but the calls won't do anything.jQueryvariable works but the$does not it means that another plugin has taken the$reference away from jQuery or that you've used$.noConflict()somewhere. Either way, we can't help you find where in your code that might be.