使用频率 | 中低 |
所属模块 | Std.dom |
成员类型 | 静态成员函数 |
Std.dom.extend方法用于扩展Std.dom的原型方法,给Std.dom实例增加新的公有成员方法.
这样的做法可以很有效的增加代码的复用性.
(该方法会同时扩展Std.dom.united)
Object Std.dom.extend(String name,Function method);
Object Std.dom.extend(Object methods);
名称 | 类型 | 描述 |
name | String | 方法名称 |
method | Function | Std.dom的成员方法 |
methods | Object | 包含多个方法的object对象 |
Std.dom.extend({
hello:function(){
return this.html("hello");
}
});
Std.dom.extend("red",function(){
return this.css("color","red");
});
//body的html内容变为hello
Std.dom("body").hello();
//body的文字颜色变为了红色
Std.dom("body").red();