javascript - JQuery $(this).attr ("name") 与 this.name

标签 javascript jquery this attr

主要区别是什么

$(this).attr("name")

this.name

技术解释是什么?

最佳答案

第一个从 DOM 元素形成的 jQuery 对象中获取属性值。第二种方法直接从 DOM 元素获取属性,因此速度更快。您应该尽可能使用原生属性。

关于javascript - JQuery $(this).attr ("name") 与 this.name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23130087/

相关文章:

jquery - 在完全离开浏览器窗口之前,我怎样才能使一堆 div 固定到 1?

javascript - 未捕获的类型错误 : Cannot read property 'then' of undefined SweetAlert & jquery

javascript - 使用 fullpage.js Bootstrap

JavaScript:将对象方法的上下文绑定(bind)到父级

c++ - 类能否使用此指针或其他方式将自身指向不同的地址?

javascript - knockout.js 引用父对象

javascript - 带 socket.io 的 Node.js : TypeError: Obj has no method 'on' at new Manager

javascript - 过滤器认为具有辅助号码的联系人

c# - 尝试访问 iis 6.0 Web 服务时出现错误 403

javascript - `this` 内部格式化函数