Using JQuery in Drupal 7
Asked 07 September, 2021
Viewed 502 times
  • 52
Votes

I'm writing my own Drupal 7 module, and like to use JQuery in it.

$('#field').toggle();

But I'm getting this error:

TypeError: Property '$' of object [object DOMWindow] is not a function

It seems that JQuery is not loaded. Otherwise $ should be defined.

Though I actually include it in the header:

<script type="text/javascript" src="http://rockfinder.de/misc/jquery.js?v=1.4.4"></script>

Do I have to do anything else to activate JQuery in Drupal? Is $ being overwritten by Drupal?

That's the website: http://rockfinder.orgapage.de

5 Answer