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中声明一个变量