在使用JQ的on()时遇到了问题
<script>
$(document).ready(function(){ //第一个按钮
$('#switcher-narrow').on('click',function(){
$('body').addClass('narrow'); //添加的样式
$('body').removeClass('large'); //移除样式
});
$('#switcher-large').on('click',function(){ //第二个按钮
$('body').addClass('large'); //添加样式
$('body').removeClass('narrow'); //移除样式
});
$('switcher-default').on('click',function(){ //第三个按钮,用于恢复默认样式
$('body').removeClass('narrow'); //移除样式
$('body').removeClass('large'); //移除样式
});
});
</script>
如果没添加第三个按钮事件,样式可以切换,没报错
接着加上了第三个按钮的事件。报错了,在console里面收到这段event.returnValue is deprecated. Please use the standard event.preventDefault() instead.