1

This jquery snippet works fine in JSfiddle...

        jQuery(document).ready(function() {
        jQuery(".link").click(function() {
        jQuery('.content-container div').fadeOut('slow');
        jQuery('#' + $(this).data('rel')).fadeIn('slow');
      });
    });

But when I insert it into the footer of my WordPress site I get the following error...

Uncaught TypeError: undefined is not a function

anyone any ideas what I am doing wrong?

ham-sandwich
  • 3,975
  • 10
  • 34
  • 46
fightstarr20
  • 11,682
  • 40
  • 154
  • 278

1 Answers1

1

Answer from 7975203:

Wordpress uses jQuery in noConflict mode by default. You need to reference it using jQuery as the variable name, not $, e.g. use

jQuery(document);

instead of

$(document);

You can easily wrap this up in a self executing function so that $ refers to jQuery again (and avoids polluting the global namespace as well), e.g.

(function ($) {
   $(document);
}(jQuery));
Community
  • 1
  • 1
Davide Pastore
  • 8,678
  • 10
  • 39
  • 53