Alex Douglas Alex Douglas - 3 months ago 10
jQuery Question

"undefined is not a function" error when calling fadeOut()

jQuery(document).ready(function($) {
document.getElementById('hp-testimonials').fadeOut(500);
}


It just gives me this error:


Uncaught TypeError: undefined is not a function


Why? A
<div>
with an
id
of "hp-testimonials" exists on the page. I don't understand why it wont fade this
<div>
out.

Answer

fadeOut() isn't a standard DOM method; it's part of jQuery. You're trying to call it on a DOM element.

Instead:

jQuery(document).ready(function($) {
  $('#hp-testimonials').fadeOut(500);
});