jQuery报错:Uncaught TypeError: _this.attr is not a function


问题:想通过延时把置灰的按钮再次复原,代码如下:

$("#sendEmailCode").on("click", function() {
    var _this = this;
    _this.setAttribute("disabled",true)
    setTimeout(function(){ 
        console.log("hh");
        _this.attr("disabled",false);
     }, 3000)
}    

js报错:Uncaught TypeError: _this.attr is not a function

解决方案:

#源码中的调用是用jQuery作为函数的
jQuery.noConflict();

把代码修改成
jQuery(_this).attr("disabled",false)
就不报错了。

参考文章:http://yoff.cn/article/13.html

--与君共勉


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM