(一)原生JS实现 - 基本类方法

时间:2014-11-23 15:41:51   收藏:0   阅读:242

1 var Class = {
2     create: function() {
3         return function() { 
4             this.initialize.apply(this, arguments); }
5     }
6 };        

对象扩展

1 var Extend = function(destination, source) {
2     for (var property in source) {
3         destination[property] = source[property];
4     }
5 };

获取DOM元素属性

 1 var Attr = function (element, key, value) {
 2     if(arguments.length == 2){
 3         if(element.getAttribute){
 4             return element.getAttribute(key) || element[key] || undefined;
 5         }
 6     }
 7     else if(arguments.length == 3){
 8         element.setAttribute(key,value);
 9     }
10 };

 

原文:http://www.cnblogs.com/huair_12/p/4116560.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!