标签:
function on(node,type,funchandler) {
node = typeof node == "string" ? document.getElementById(node) : node;
if (!document.all) {
node.addEventListener(type, funchandler);
} else {
node.attachEvent("on"+type,funchandler);
}
}
function trim(ostr) {
return ostr.replace(/^\s+|\s+$/g, ‘‘);
}
function isNumber(s) {
return !isNaN(s);
}
function isString(s) {
return typeof s == "string";
}
function isBoolean(s) {
return typeof s == ‘boolean‘;
}
function isNull(s) {
return s == null;
}
function isUndefined(s) {
return typeof s == "undefined";
}
function isEmpty(s) {
return /^\s*$/.test(s)
}
function isArray(s) {
return s instanceof Array;
}
/*
claaName:类名
root:根元素
tag:标签类型
*/
function getElementsByClassName(claaName, root, tag) {
var arr = [];
if (root) {
root = typeof root == ‘string‘ ? document.getElementById(root) : root;
} else {
root = document.body;
}
tag = tag || ‘*‘;
var eles = root.getElementsByTagName(tag);
for (var i = 0; i < eles.length ; i++) {
for (var j = 0, k = eles[i].className.split(/\s+/g), l = k.length; j < l; j++) {
if (k[j] == claaName) {
arr.push(eles[i]);
break;
}
}
}
return arr;
}
标签:
原文地址:http://www.cnblogs.com/alphafly/p/4771893.html