Created
September 11, 2013 05:50
-
-
Save hkongm/6519766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//取得ID | |
var $ = function (id) { | |
return "string" == typeof id ? document.getElementByIdx_x(id) : id; | |
}; | |
// 对象继承 | |
var Extend = function(destination, source) { | |
for (var property in source) { | |
destination[property] = source[property]; | |
} | |
return destination; | |
} | |
// 取得当前样式 | |
var CurrentStyle = function(element){ | |
return element.currentStyle || document.defaultView.getComputedStyle(element, null); | |
} | |
// 方法绑定 | |
var Bind = function(object, fun) { | |
var args = Array.prototype.slice.call(arguments).slice(2); | |
return function() { | |
return fun.apply(object, args.concat(Array.prototype.slice.call(arguments))); | |
} | |
} | |
// 数组each | |
var forEach = function(array, callback, thisObject){ | |
if(array.forEach){ | |
array.forEach(callback, thisObject); | |
}else{ | |
for (var i = 0, len = array.length; i < len; i++) { callback.call(thisObject, array[i], i, array); } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment