For some reason I am getting an Uncaught TypeError when I try and execute the following code.
jQuery(function($){
$(document).ready(function() {
$(".block").click(function() {
var currentElement = $(this).find(".form-group");
currentElement.slideToggle("slow");
});
});
});
I get the following error
Uncaught TypeError: currentElement.slideToggle is not a function
at HTMLDivElement.<anonymous> (index.js:6)
at HTMLDivElement.dispatch (jquery-3.1.1.slim.min.js:3)
at HTMLDivElement.q.handle (jquery-3.1.1.slim.min.js:3)
However when I call currentElement.toggle()
It works as expected and I do not get any errors.
Can anyone explain why this is?
The problem here is you are using the slim version which excludes the effects like the animation expected from slideToggle
; so the function isn't defined. Just switch to the normal version.
From the Jquery Page
Slim build
Sometimes you don’t need ajax, or you prefer to use one of the many standalone libraries that focus on ajax requests. And often it is simpler to use a combination of CSS and class manipulation for all your web animations. Along with the regular version of jQuery that includes the ajax and effects modules, we’ve released a “slim” version that excludes these modules. All in all, it excludes ajax, effects, and currently deprecated code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With