我在使用jQuery的toggle函数的时候出现了这样一个问题
这是我的代码:
$(document).ready(function() {
$("#button1").toggle(
function() {
alert(1);
},
function() {
alert(2);
},
function(){
alert(3);
});
});
然后这个是异常:
jQuery.Deferred exception: r.easing[this.easing] is not a function TypeError: r.easing[this.easing] is not a function
at Xa.run (http://localhost:8080/JSTest/JavaScript/jquery-3.0.0.min.js:3:23582)
at i (http://localhost:8080/JSTest/JavaScript/jquery-3.0.0.min.js:3:26835)
at Function.r.fx.timer (http://localhost:8080/JSTest/JavaScript/jquery-3.0.0.min.js:3:30432)
at gb (http://localhost:8080/JSTest/JavaScript/jquery-3.0.0.min.js:3:27668)
at HTMLButtonElement.g (http://localhost:8080/JSTest/JavaScript/jquery-3.0.0.min.js:3:28879)
at Function.dequeue (http://localhost:8080/JSTest/JavaScript/jquery-3.0.0.min.js:3:2716)
at HTMLButtonElement.<anonymous> (http://localhost:8080/JSTest/JavaScript/jquery-3.0.0.min.js:3:3151)
at Function.each (http://localhost:8080/JSTest/JavaScript/jquery-3.0.0.min.js:2:2813)
at r.each (http://localhost:8080/JSTest/JavaScript/jquery-3.0.0.min.js:2:1003)
at r.queue (http://localhost:8080/JSTest/JavaScript/jquery-3.0.0.min.js:3:3056)
我试过stackoverflow上的方法,引入了什么jquery-ui,可是引入了之后不仅还是不行,jquery-ui还报错了,这个怎么解决啊,我是照着书上敲的啊。
迷茫2017-04-11 11:21:07
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").toggle(
function() {
alert(1);
},
function() {
alert(2);
},
function(){
alert(3);
}
);
});
</script>
</head>
<body>
<button>请点击这里,来切换不同的背景颜色</button>
</body>
</html>