Jquery 中的$(this) 和javascript中的this

  this 是 JavaScript 中的关键字。 $(this) 可以认为是用 jQuery 包装过 JavaScript 中的 this,包装后 $(this) 就会继承 jQuery 的方法。

本质就是JavaScript与jQuery对象的转换

$('a').click(function(){ // 这里的 this 指向当前点击的DOM节点,也就是a。可以调用DOM方法,比如this.getAttribute, this.tagName ... // 这里的 $(this) 表示包装过的一个 jQuery 对象,拥有 jQuery 的一些方法,比如 $(this).addClass(), $(this).hide() ... });

总而言之:$(this)代表元素本身
原文地址:https://www.cnblogs.com/zhaoyingjie/p/6124490.html