【发布时间】:2011-03-26 01:32:50
【问题描述】:
我有这个用于渐进式披露的旧 jquery 脚本:(注意 $(this).text('more...') 代码会更改按钮文本。
<!--for more/less progressive disclosure-->
<script >
$(document).ready(function () {
$('div.view').hide();
$('div.slide').toggle(function () {
this.style.background = '#7D4F4E';
$(this).text('less...').siblings('div.view').fadeIn('fast');
}, function () {
this.style.background = '#B0B07F';
$(this).text('more...').siblings('div.view').fadeOut('fast');
});
});
</script>
它工作正常,但我会使用下面的那个,我希望这个 jquery 脚本具有相同的文本更改(对于按钮)。如何将上述代码中的文本更改应用于底部的新脚本?
<!--a real good progressive disclosure-->
<script type="text/javascript">
$(document).ready(function () {
$('.mover').hide();
$('#slideToggle').click(function () {
$(this).siblings('.mover').slideToggle();
});
$('.toggleSlow').click(function () {
$(this).siblings('.mover').toggle('normal');
});
$('#fadeInOut').toggle(function () {
$(this).siblings('.mover').fadeIn('normal');
}, function () {
$(this).siblings('.mover').fadeOut('normal');
});
$('#animate').click(function () {
$(this).siblings('.mover').slideDown(5500).fadeOut(7300);
});
});
</script>
【问题讨论】:
-
如果不知道页面上有哪些元素,这真的很令人困惑。具体来说,第二个脚本中按钮的类/ID 是什么?
-
(显示 - 隐藏)/* 渐进式披露 */ .pusher{background:#3B6670;颜色:#F0E3C0;光标:指针;显示:表格;填充:3px 8px;字体粗细:900;字体大小:16px;字体粗细:粗体;显示:内联;浮动:对;明确:两者; -moz-边界半径:10px; -webkit-border-radius:10px;边框半径:10px;边距顶部:0;边距底部:10px}; .pusher:hover{背景:#0D1F30}
标签: jquery disclosure progressive