Saturday, 28 September 2013

Javascript: onclick does not call function

Javascript: onclick does not call function

When I run the following code, the alert messages shows up but this.test()
does not run.
document.onclick = function(e) {
alert("Hi");
this.test();
};
However when I try this:
document.onclick = this.test();
this.test() will run.

No comments:

Post a Comment