Difference between $(this) and this in jquery

前端 未结 7 2087
灰色年华
灰色年华 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:55

    $(this) - represent current DOM element on which event this function is called

    The this keyword - In JavaScript this always refers to the “owner” of the function we're executing, or rather, to the object that a function is a method of.

提交回复
热议问题