好吧所以即时通讯使用此处slide menu的幻灯片菜单,我想更改按钮文字,当它点击显示或隐藏时,例如,这是我目前为止只有顶级菜单的代码离线安装
<button id="showTop" class="menubtn" data-text-swap="Show">Show</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/modernizr.js"></script>
<script src="js/classie.js"></script>
<script>
var menuTop = document.getElementById( 'cbp-spmenu-s3' ),
showTop = document.getElementById( 'showTop' ),
body = document.body;
showTop.onclick = function() {
classie.toggle( this, 'active1' );
classie.toggle( menuTop, 'cbp-spmenu-open' );
disableOther( 'showTop' );
};
function disableOther( button ) {
if( button !== 'showTop' ) {
classie.toggle( showTop, 'disabled' );
}
}
</script>
&#13;
中提到的内容
$('.SeeMore2').click(function(){
var $this = $(this);
$this.toggleClass('SeeMore2');
if($this.hasClass('SeeMore2')){
$this.text('See More');
} else {
$this.text('See Less');
}
});
&#13;
但是没有帮助,所以我可以对showTop.onclick函数下的第一个脚本做些什么来改变按钮文本而不仅仅是类。
答案 0 :(得分:0)
你在点击功能中遗漏了这个:
showTop.onclick = function() {
if (showTop.innerHTML == 'Show') {
showTop.innerHTML = 'Hide';
} else {
showTop.innerHTML = 'Show';
};