Skip to content

Instantly share code, notes, and snippets.

@input
Created January 22, 2012 20:53
Show Gist options
  • Save input/1658743 to your computer and use it in GitHub Desktop.
Save input/1658743 to your computer and use it in GitHub Desktop.
Drupal 7 jQuery Demo
<a href="#" id="togg-link">Click this link to toggle the content displayed below</a>
<div id="togg">Content to be toggled.</div>
(function ($) {
Drupal.behaviors.togg = {
attach: function (context, settings) {
$('a#togg-link:not(.togg-processed)', context).addClass('togg-processed').each(function() {
$(this).click(function() {
$("div#togg").toggle(400);
return false;
});
});
}
};
})(jQuery);
Usage
-----
- Output the HTML somewhere (e.g. in a node body)
- Add the js to your theme's scripts.js file.
Note: ensure there is only one '(function ($) {' '})(jQuery);' in the file.
If this already exists do not repeat it.
See: http://lhmdesign.com/drupal-jquery-demo for a demo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment