简体   繁体   中英

How do you use the click event properly to call another function within the class?

I was confused on how to use the click event in order to call another function within the class.

$.fn.imageareaselect(image)
{ 
this.click(function(){
$.fn.pinpointImage.add(image);
});
}

The selector that is passed into this function is an image. I wan't to make it so when you click the image it calls that function.

jQuery's kinda funny about passing an HTML element when you'd expect a jQuery one. try using $(this) instead of this .

Also, jQuery functions like to take functions as params, but i'm not sure exactly what this code is trying to do now. The first "(image)" should probably be "= function(image)" instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM