$(this) 和 this

在使用 jQuery 时,$(this) 和 this 具体指:

    this :是当前 DOM 对象;

    $(this) 是jQuery对象;

例子:

<input type="text">
$(function(){
    $("#search_id").focus(function(){
        alert(this);   //弹出值为: object HTMLInputElement
        alert($(this)); //弹出值为:object object
        })
       })

jQuery 对象和 DOM 对象 是可以相互转化的 : jQuery  ($varJD) 转DOM  (JD) :JD=$varJD[0] ; JD=$varJD.get(0) 。DOM  (JD)转 jQuery  ($varJD):$varJD=$(JD);

可以带入上边验证:$(this)[0],将会弹出 object HTMLInputElement。

原文地址:https://www.cnblogs.com/CHWYH/p/5170878.html