javascript - jQuery问题:"TypeError: r.easing[this.easing] is not a function"

查看:241
本文介绍了javascript - jQuery问题:"TypeError: r.easing[this.easing] is not a function"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

我在使用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方法的时候, 会报方法不存在

这篇关于javascript - jQuery问题:&quot;TypeError: r.easing[this.easing] is not a function&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆