JS代码如下:
/**
* JS类
*
* @param
* @arrange (512.笔记) jb51.cc
**/
var Class = function() {
var klass = function() {
this.init.apply(this,arguments);
};
klass.prototype.init = function() {
};
return klass;
};
var Person = new Class;
Person.prototype.init = function(opts) {
opts = $.extend({
"element": 'Box'
},opts || {});
this.opts = opts;
this.element = $(opts.element);
this.render();
};
Person.prototype.render = function() {
var elEl = $(this.element);
var opts = this.opts;
elEl.html(opts.name + ',' + opts.age);
};
/**
* 开始执行脚本
*/
$(function() {
var person = new Person({
element: '.myBox2', name: '李四', age: 55
});
});
// 来自:编程之家 jb51.cc(jb51.cc)
原文链接:https://www.f2er.com/js/527638.html