Skip to content

Instantly share code, notes, and snippets.

@hkongm
Created September 11, 2013 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hkongm/6519766 to your computer and use it in GitHub Desktop.
Save hkongm/6519766 to your computer and use it in GitHub Desktop.
//取得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