想在js里实现类的封装,遇到一个问题。具体的请看代码。问题见注释
var TestClass; if (TestClass == undefined) { TestClass = function(){ } } TestClass.prototype.init = function (options) { $(".alert_click").click(function(){ this.popup("test"); //这样的代码会提示popup未定义。如果想在此处调用popup应该怎么做? }); }; TestClass.prototype.popup = function (value) { alert(value); } $(function(){ var testClass = new TestClass(); testClass.init(); }