我已在 drupal 7 中成功使用此代码,但不知道如何实现最初未显示的内容的默认行为。我们需要链接后的内容只有在单击链接后才可见。
http://mydrupalblog.lhmdesign.com/drupal-theming-jquery-basics-inc-drupal-behaviors
这是这个演示,我们需要这个演示的相反行为,
http://www.lhmdesign.com/drupal-jquery-demo
先感谢您
我已在 drupal 7 中成功使用此代码,但不知道如何实现最初未显示的内容的默认行为。我们需要链接后的内容只有在单击链接后才可见。
http://mydrupalblog.lhmdesign.com/drupal-theming-jquery-basics-inc-drupal-behaviors
这是这个演示,我们需要这个演示的相反行为,
http://www.lhmdesign.com/drupal-jquery-demo
先感谢您
---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') 引用的任何链接来监听点击。内容最初是用内联 CSS 隐藏的,因为 jQuery 会在切换时直接更改它。