Onclick event getting called automatically
问题 I wrote a JavaScript class called MyClass in which I've defined a method closeThis MyClass = function() { this.closeThis = function() { document.getElementById("hidePane").style.display = 'none'; } } Now, in my html, i'm trying to call that as follows... <script type="text/javascript"> function callThis() { var myclassObj = new MyClass(); document.getElementById("closeButton").onclick = myclassObj.closeThis(); } </script> The above callThis will be called when I clicked on a button. The