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

2023-05-25,,

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

$("#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

--与君共勉

jQuery报错:Uncaught TypeError: _this.attr is not a function的相关教程结束。

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

下载本文的Word格式文档,以方便收藏与打印。