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

--与君共勉
原文地址:https://www.cnblogs.com/steveshao/p/11696773.html