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?
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?
Share Improve this question edited Mar 7, 2017 at 16:55 DaniP 38.3k9 gold badges67 silver badges74 bronze badges asked Mar 7, 2017 at 16:34 LennyLenny 1932 silver badges12 bronze badges 01 Answer
Reset to default 8The 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 bination 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.