Difference between $(this) and this in jquery

前端 未结 7 2093
灰色年华
灰色年华 2020-11-28 07:40

What is the fundamental difference between using $(this) vs this

$(\'.viewComments\').click(function(ev){
    //returns the desired value
    alert(this.getA         


        
7条回答
  •  余生分开走
    2020-11-28 07:50

    in jQuery the $() notation is a shorthand for the jQuery selector, so if you say $(this) you are asking jQuery to re-select your object. Then you have the usual jQuery functions available.
    Then, this is the object selected by the outer jQuery call (JavaScript).

提交回复
热议问题