this 、$this 、$(this)

1.this 、$this 、$(this)

<div id="testA">
    <a>1</a>
    <a>2</a>
    <a>3</a>
    <a>4</a>
    <a>5</a>
</div>
$("#testA a").click(function(){
     console.log(this);
     console.log($(this));
});

打印结果

因此:this其实是一个html 元素;$(this)是一个JQuery对象

用法:this.id="test" ;  $(this).attr("id","test");

$this:在jQuery中声明一个变量

 

 

 

posted @ 2018-11-15 14:25  南山湖畔  阅读(212)  评论(0编辑  收藏  举报