what is the meaning of the word “this” in Jquery script

前端 未结 3 591
余生分开走
余生分开走 2021-01-29 07:51

Hello I\'m a newcomer in JavaScript and JQuery language. I started to see some examples of JQuery script.

i have the following code segment:

 

        
3条回答
  •  野性不改
    2021-01-29 08:29

    Most time in such snippets of jQuery this refers to HTMLElement object. Here this is the HTMLParagraphElement or P tag object.
    $(this) refers to the jQuery object created from current HTMLElement object.

    But keep in mind in JavaScript the meaning this changes depending on where the function is called.

提交回复
热议问题