티스토리 뷰

728x90

예전에 북마크 해둔게 있었다.

this와 $(this)의 차이

 

this는 DOM object 이다. 

 

$(this)는 javascript의 this를 jQuery wrapper로 한번 감싼거라고 생각하면 된다.

 

$(this)는 jQuery wrapper로 감싼 object이기 때문에 jquery method를 사용할 수 있다. 그러나 javascript의 native method들은 사용할 수 없다.

 

https://stackoverflow.com/questions/3633270/difference-between-this-and-this-in-jquery

 

Difference between $(this) and this in jquery

What is the fundamental difference between using $(this) vs this $('.viewComments').click(function(ev){ //returns the desired value alert(this.getAttribute('id')); //Gives an error sa...

stackoverflow.com

 

728x90
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함