首页 > 代码库 > base.js

base.js

function on(node,eventType,handler){    //e=window.event||e;   node=typeof node=="string"?document.getElementById(node):node;   if(document.all) //IE   {      node.attachEvent("on"+eventType,handler);   }   else   {      node.addEventListener(eventType,handler,false);   }}//on(btn,"click",function(){alert("1")});1、trim()function trim(ostr){   return ostr.replace(/^\s+|\s+$/g,"");}2、isNumber、isString、isBoolean、isFunction、isNull、isUndefined、isEmpty、isArrayfunction isNumber(s){   return !isNaN(s);}function isString(s){  return typeof s==="string";}function isBoolean(s){  return typeof s==="boolean";}function isFunction(s){  return typeof s==="function";}function isNumm(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;}