jsp文件中jsp
var alertLogic; $(document).ready(function(){ alertLogic = new AlertLogic("alert-test"); });
======================================================================= alert.js文件中this
var AlertLogic = function(dataListId){ //对象属性 this.dataId = dataListId; this._onCreate(); }; //经过prototype扩展对象实例方法,一样适用于String AlertLogic.prototype = { /*初始化方法 *主要声明一些变量,画面初始化等 */ _onCreate : function () { var logic = this; ... logic._initCommandSet(); }, /*画面事件声明*/ _initCommandSet : function () { //点击事件 $(".clickTest").click(function(){ ... return false; }); }, }; String.prototype.startWith = function(str){};