我有一个可以切换我的div的工作脚本,它运行得很好,但我不知道如何在单击时更改按钮文本。当显示spread div时,我需要按钮文本为“隐藏Spreads”,当未显示spread div时,按钮文本为“显示Spreads”。
脚本:
$(document).ready(function(){
$(".spread").show();
$(".show_hide").show();
$('.show_hide').click(function(){
$(".spread").toggle();
});
});
按钮:
<input type="button" class="show_hide" value="Hide Spreads" />
.val()
。允许时会接受作为答案。 - Mark Jones