---SCRIPT.JS コンテンツ---
jQuery:
(function ($, Drupal, window, document, undefined) {
Drupal.behaviors.customCode = {
attach: function () {
$('.myLinks').click(function () {
$('#content').slideToggle();
});
}
};
})(jQuery, Drupal, this, this.document);
HTML:
<div>
<a href="#" class="myLinks">This is your link</a>
<div id="content" style="display: none;">This is the hidden content</div>
</div>
CSS:
#content {
width: 100px;
height: 100px;
position: relative;
bottom: 0;
}
div {
position: relative;
width: 500px;
height: 100%;
}
これにより、$('.myLinks') で参照するリンクがクリックをリッスンするように設定されます。コンテンツは、切り替え時に jQuery によって直接変更されるため、最初はインライン CSS で非表示になっています。