Skip to content

Instantly share code, notes, and snippets.

@carwin
Created September 12, 2012 17:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save carwin/3708494 to your computer and use it in GitHub Desktop.
Save carwin/3708494 to your computer and use it in GitHub Desktop.
Drupal 7: Proper implementation of jQuery in a Drupal theme.
(function ($) {
Drupal.behaviors.themename = {
attach: function(context, settings) {
// Add a hover class to nav items.
$('.mainnav nav a')
.hover(
function() {
$(this).addClass('hover');
},
function() {
$(this).removeClass('hover');
}
);// end hover
}}
}) (jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment