1

I have a Drupal site with a purchased theme - see it here.

The theme includes jQuery 2.x and Bootstrap in the <head> section of the page, but trying to access the $variable gives Uncaught TypeError: $ is not a function

Erik Johnson
  • 858
  • 1
  • 7
  • 29

1 Answers1

0

Drupal stores jQuery in a variable called jQuery (using jQuery's noConflict mode - see drupal.js) rather than $ to avoid conflicts with other libraries like Prototype.

// Allow other JavaScript libraries to use $.
jQuery.noConflict();

You can just do:

jQuery(document).ready(function($){
    // normal jQuery stuff here
    $.whatever
});
ceejayoz
  • 176,543
  • 40
  • 303
  • 368