我在使用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还报错了,这个怎么解决啊,我是照着书上敲的啊。
你用的jq版本是3.0.0, 而toggle函数自jq 1.9开始就已经被移除了, 所以你调用toggle方法的时候, 会报方法不存在