jQuery $.proxy()
bind this
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>/*from ww w. ja v a 2 s . c om*/ <script> $(document).ready(function(){ test = function(){ this.txt = "This is an object property"; $("div").click($.proxy(this.myClick, this)); }; test.prototype.myClick = function(event){ document.getElementById("demo").innerHTML = this.txt +" " + event.currentTarget.nodeName; }; var x = new test(); }); </script> </head> <body> <p id="demo"></p> <div>This is a div element.</div> </body> </html>