jquery / learn.jquery.com

jQuery Learning Center web site content
https://learn.jquery.com
Other
924 stars 484 forks source link

can not access the element on which function is called #779

Closed zeeeuu closed 6 years ago

zeeeuu commented 6 years ago

[a simple jquery plugin ] (https://jsfiddle.net/28jof5th/4/)

in the fiddle on line 147 when i try to do console.log(this) then it gives the window object not the element which is passed in the function call on line 166 $('#loadImage').loadImage() with the id loadImage. It leads to bind a click event handler on the whole window but not on the element. It means event fires when where ever i click on the page. so my problem is why i am not able to access the element but window object at line 147

dmethvin commented 6 years ago

This is a good StackOverflow question.