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