Uncaught TypeError: $(...).ready is not a function

Nick M

Hi I Know this has been asked before but no answer on here seems to help me.

I have this block of JS:

$(document).ready(function() {
    $('.play-icon-hover').hover(function() {
         $('.cms-model-banner-overlay').addClass('.cms-model-banner-overlay-active');
        }, function() {
         $('.cms-model-banner-overlay').removeClass('.cms-model-banner-overlay-active');
    });
});

And I seem to be getting this error but I have no idea why?

Uncaught TypeError: $(...).ready is not a function

Thanks

Praveen Kumar Purushothaman

You are using Prototype.js as well as jQuery.js. If you wanna use jQuery, it is better to encapsulate your code inside an IIFE like this:

(function ($) {
  // jQuery code using $
})(jQuery);

So the solution for your issue is either you change $ to jQuery:

jQuery(document).ready(function() {
  jQuery('.play-icon-hover').hover(function() {
    jQuery('.cms-model-banner-overlay').addClass('.cms-model-banner-overlay-active');
  }, function() {
    jQuery('.cms-model-banner-overlay').removeClass('.cms-model-banner-overlay-active');
  });
});

Or, use a IIFE:

(function ($) {
  $(document).ready(function() {
    $('.play-icon-hover').hover(function() {
      $('.cms-model-banner-overlay').addClass('.cms-model-banner-overlay-active');
    }, function() {
      $('.cms-model-banner-overlay').removeClass('.cms-model-banner-overlay-active');
    });
  });
})(jQuery);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

JQuery: Uncaught TypeError: jQuery(...).ready(...) is not a function

TypeError: jQuery(...).ready(...) is not a function

Uncaught TypeError: Function is not a function

Uncaught TypeError: Cannot read property 'ready' of null

Uncaught TypeError: $(...).jsGrid is not a function

Uncaught TypeError: $(…).on is not a function

Uncaught TypeError: $(...).accordion is not a function

Uncaught TypeError: $(...).formSelect is not a function

Uncaught TypeError: $(...).stellar is not a function

Uncaught TypeError: $(...).tooltip is not a function

Uncaught TypeError: $(...).pickadate is not a function

Uncaught TypeError: 'download' is not a function

Uncaught TypeError: $(...).tableDnD is not a function

Javascript: Uncaught TypeError: not a function

Uncaught TypeError: #<Object> is not a function

Uncaught TypeError: $.post is not a function

Uncaught TypeError: map is not a function

Uncaught TypeError: Object (...) is not a function

Uncaught TypeError Object is not a function

Uncaught TypeError: .slideToggle is not a function

Uncaught TypeError: $(...).waterwheelCarousel is not a function

"Uncaught TypeError: $ is not a function" in WordPress

Uncaught TypeError: .unshift is not a function

Uncaught TypeError: dispatch(...).then is not a function

Uncaught TypeError: $(...).selectize is not a function

Uncaught TypeError: $ is not a function on weebly

Uncaught TypeError: getFullYear is not a function

Uncaught TypeError: $(...).draggable is not a function

Uncaught TypeError: a(...).countdown is not a function