转载 Javascript 使用 "大杂烩"

     这是我早期在网上看的javascript学习方法,觉得很不错,就保存到word了,这几天学习Js,再看了一遍,对初学或者已经会Js的程序员来说,还是可以学习的。还有大家如果有更好的Js学习方法,可以提供下噢。谢谢!

1.Javascript 数组API

<!--[if !supportLists]-->1.  <!--[endif]-->//定义数组  

<!--[if !supportLists]-->2.  <!--[endif]-->        var pageIds = new Array();  

<!--[if !supportLists]-->3.  <!--[endif]-->        pageIds.push('A');  

<!--[if !supportLists]-->4.  <!--[endif]-->  

<!--[if !supportLists]-->5.  <!--[endif]-->        数组长度  

<!--[if !supportLists]-->6.  <!--[endif]-->        pageIds.length;  

<!--[if !supportLists]-->7.  <!--[endif]-->  

<!--[if !supportLists]-->8.  <!--[endif]-->//shift:删除原数组第一项,并返回删除元素的值;如果数组为空则返回undefined   

<!--[if !supportLists]-->9.  <!--[endif]-->var a = [1,2,3,4,5];   

<!--[if !supportLists]-->10.<!--[endif]-->var b = a.shift(); //a:[2,3,4,5]   b:1   

<!--[if !supportLists]-->11.<!--[endif]-->  

<!--[if !supportLists]-->12.<!--[endif]-->//unshift:将参数添加到原数组开头,并返回数组的长度   

<!--[if !supportLists]-->13.<!--[endif]-->var a = [1,2,3,4,5];   

<!--[if !supportLists]-->14.<!--[endif]-->var b = a.unshift(-2,-1); //a:[-2,-1,1,2,3,4,5]   b:7   

<!--[if !supportLists]-->15.<!--[endif]-->//注:在IE6.0下测试返回值总为undefined,FF2.0下测试返回值为7,所以这个方法的返回值不可靠,需要用返回值时可用splice代替本方法来使用。   

<!--[if !supportLists]-->16.<!--[endif]-->  

<!--[if !supportLists]-->17.<!--[endif]-->//pop:删除原数组最后一项,并返回删除元素的值;如果数组为空则返回undefined   

<!--[if !supportLists]-->18.<!--[endif]-->var a = [1,2,3,4,5];   

<!--[if !supportLists]-->19.<!--[endif]-->var b = a.pop(); //a:[1,2,3,4]   b:5   

<!--[if !supportLists]-->20.<!--[endif]-->  

<!--[if !supportLists]-->21.<!--[endif]-->//push:将参数添加到原数组末尾,并返回数组的长度   

<!--[if !supportLists]-->22.<!--[endif]-->var a = [1,2,3,4,5];   

<!--[if !supportLists]-->23.<!--[endif]-->var b = a.push(6,7); //a:[1,2,3,4,5,6,7]   b:7   

<!--[if !supportLists]-->24.<!--[endif]-->  

<!--[if !supportLists]-->25.<!--[endif]-->//concat:返回一个新数组,是将参数添加到原数组中构成的   

<!--[if !supportLists]-->26.<!--[endif]-->var a = [1,2,3,4,5];   

<!--[if !supportLists]-->27.<!--[endif]-->var b = a.concat(6,7); //a:[1,2,3,4,5]   b:[1,2,3,4,5,6,7]   

<!--[if !supportLists]-->28.<!--[endif]-->  

<!--[if !supportLists]-->29.<!--[endif]-->//splice(start,deleteCount,val1,val2,):从start位置开始删除deleteCount项,并从该位置起插入val1,val2,   

<!--[if !supportLists]-->30.<!--[endif]-->var a = [1,2,3,4,5];   

<!--[if !supportLists]-->31.<!--[endif]-->var b = a.splice(2,2,7,8,9); //a:[1,2,7,8,9,5]   b:[3,4]   

<!--[if !supportLists]-->32.<!--[endif]-->var b = a.splice(0,1); //同shift   

<!--[if !supportLists]-->33.<!--[endif]-->a.splice(0,0,-2,-1); var b = a.length; //同unshift   

<!--[if !supportLists]-->34.<!--[endif]-->var b = a.splice(a.length-1,1); //同pop   

<!--[if !supportLists]-->35.<!--[endif]-->a.splice(a.length,0,6,7); var b = a.length; //同push   

<!--[if !supportLists]-->36.<!--[endif]-->  

<!--[if !supportLists]-->37.<!--[endif]-->//reverse:将数组反序   

<!--[if !supportLists]-->38.<!--[endif]-->var a = [1,2,3,4,5];   

<!--[if !supportLists]-->39.<!--[endif]-->var b = a.reverse(); //a:[5,4,3,2,1]   b:[5,4,3,2,1]   

<!--[if !supportLists]-->40.<!--[endif]-->  

<!--[if !supportLists]-->41.<!--[endif]-->//sort(orderfunction):按指定的参数对数组进行排序   

<!--[if !supportLists]-->42.<!--[endif]-->var a = [1,2,3,4,5];   

<!--[if !supportLists]-->43.<!--[endif]-->var b = a.sort(); //a:[1,2,3,4,5]   b:[1,2,3,4,5]   

<!--[if !supportLists]-->44.<!--[endif]-->  

<!--[if !supportLists]-->45.<!--[endif]-->//slice(start,end):返回从原数组中指定开始下标到结束下标之间的项组成的新数组   

<!--[if !supportLists]-->46.<!--[endif]-->var a = [1,2,3,4,5];   

<!--[if !supportLists]-->47.<!--[endif]-->var b = a.slice(2,5); //a:[1,2,3,4,5]   b:[3,4,5]   

<!--[if !supportLists]-->48.<!--[endif]-->  

<!--[if !supportLists]-->49.<!--[endif]-->//join(separator):将数组的元素组起一个字符串,以separator为分隔符,省略的话则用默认用逗号为分隔符   

<!--[if !supportLists]-->50.<!--[endif]-->var a = [1,2,3,4,5];   

<!--[if !supportLists]-->51.<!--[endif]-->var b = a.join("|"); //a:[1,2,3,4,5]   b:"1|2|3|4|5"   

2.Dom最常用的API

<!--[if !supportLists]-->1.  <!--[endif]-->document方法:   

<!--[if !supportLists]-->2.  <!--[endif]-->getElementById(id) Node 返回指定结点的引用   

<!--[if !supportLists]-->3.  <!--[endif]-->getElementsByTagName(name) NodeList 返回文档中所有匹配的元素的集合   

<!--[if !supportLists]-->4.  <!--[endif]-->createElement(name) Node Node   

<!--[if !supportLists]-->5.  <!--[endif]-->createTextNode(text) Node 创建一个纯文本结点   

<!--[if !supportLists]-->6.  <!--[endif]-->ownerDocument Document 指向这个节点所属的文档   

<!--[if !supportLists]-->7.  <!--[endif]-->documentElement Node 返回html节点   

<!--[if !supportLists]-->8.  <!--[endif]-->document.body Node 返回body节点   

<!--[if !supportLists]-->9.  <!--[endif]-->  

<!--[if !supportLists]-->10.<!--[endif]-->element方法:   

<!--[if !supportLists]-->11.<!--[endif]-->getAttribute(attributeName) String 返回指定属性的值   

<!--[if !supportLists]-->12.<!--[endif]-->setAttribute(attributeName,value) String 给属性赋值   

<!--[if !supportLists]-->13.<!--[endif]-->removeAttribute(attributeName) String 移除指定属性和它的值   

<!--[if !supportLists]-->14.<!--[endif]-->getElementsByTagName(name) NodeList 返回结点内所有匹配的元素的集合   

<!--[if !supportLists]-->15.<!--[endif]-->  

<!--[if !supportLists]-->16.<!--[endif]-->node方法:   

<!--[if !supportLists]-->17.<!--[endif]-->appendChild(child) Node 给指定结点添加一个新的子结点   

<!--[if !supportLists]-->18.<!--[endif]-->removeChild(child) Node 移除指定结点的子结点   

<!--[if !supportLists]-->19.<!--[endif]-->replaceChild(newChild,oldChild) Node 替换指定结点的子结点   

<!--[if !supportLists]-->20.<!--[endif]-->insertBefore(newChild,refChild) Node 在同一层级的结点前面插入新结点   

<!--[if !supportLists]-->21.<!--[endif]-->hasChildNodes() Boolean 如果结点有子结点则返回true   

<!--[if !supportLists]-->22.<!--[endif]-->  

<!--[if !supportLists]-->23.<!--[endif]-->node属性:   

<!--[if !supportLists]-->24.<!--[endif]-->nodeName String 以字符串的格式存放结点的名称   

<!--[if !supportLists]-->25.<!--[endif]-->nodeType String 以整型数据格式存放结点的类型   

<!--[if !supportLists]-->26.<!--[endif]-->nodeValue String 以可用的格式存放结点的值   

<!--[if !supportLists]-->27.<!--[endif]-->parentNode Node 指向结点的父结点的引用   

<!--[if !supportLists]-->28.<!--[endif]-->childNodes NodeList 指向子结点的引用的集合   

<!--[if !supportLists]-->29.<!--[endif]-->firstChild Node 指向子结点结合中的第一个子结点的引用   

<!--[if !supportLists]-->30.<!--[endif]-->lastChild Node 指向子结点结合中的最后一个子结点的引用   

<!--[if !supportLists]-->31.<!--[endif]-->previousSibling Node 指向前一个兄弟节点;如果这个节点就是兄弟节点,那么该值为null   

<!--[if !supportLists]-->32.<!--[endif]-->nextSibling Node 指向后一个兄弟节点;如果这个节点就是兄弟节点,那么该值为null 

3.常用的数字函数

<!--[if !supportLists]-->1.  <!--[endif]-->·数字型(Number)   

<!--[if !supportLists]-->2.  <!--[endif]-->  1.声明   

<!--[if !supportLists]-->3.  <!--[endif]-->    var i = 1;   

<!--[if !supportLists]-->4.  <!--[endif]-->    var i = new Number(1);   

<!--[if !supportLists]-->5.  <!--[endif]-->  

<!--[if !supportLists]-->6.  <!--[endif]-->  2.字符串与数字间的转换   

<!--[if !supportLists]-->7.  <!--[endif]-->    var i = 1;   

<!--[if !supportLists]-->8.  <!--[endif]-->    var str = i.toString();     //结果: "1"   

<!--[if !supportLists]-->9.  <!--[endif]-->    var str = new String(i);    //结果: "1"   

<!--[if !supportLists]-->10.<!--[endif]-->    i = parseInt(str);          //结果: 1   

<!--[if !supportLists]-->11.<!--[endif]-->    i = parseFloat(str);        //结果: 1  

<!--[if !supportLists]-->12.<!--[endif]-->      

<!--[if !supportLists]-->13.<!--[endif]-->    //注意: parseInt,parseFloat会把一个类似于"32G"的字符串,强制转换成32   

<!--[if !supportLists]-->14.<!--[endif]-->  

<!--[if !supportLists]-->15.<!--[endif]-->  3.判断是否为有效的数字   

<!--[if !supportLists]-->16.<!--[endif]-->    var i = 123;  var str = "string";   

<!--[if !supportLists]-->17.<!--[endif]-->    iftypeof i == "number" ){ }   //true   

<!--[if !supportLists]-->18.<!--[endif]-->      

<!--[if !supportLists]-->19.<!--[endif]-->    //某些方法(如:parseInt,parseFloat)会返回一个特殊的值NaN(Not a Number)   

<!--[if !supportLists]-->20.<!--[endif]-->    //请注意第2点中的[注意],此方法不完全适合判断一个字符串是否是数字型!!   

<!--[if !supportLists]-->21.<!--[endif]-->    i = parseInt(str);   

<!--[if !supportLists]-->22.<!--[endif]-->    if( isNaN(i) ){ }   

<!--[if !supportLists]-->23.<!--[endif]-->      

<!--[if !supportLists]-->24.<!--[endif]-->  4.数字型比较   

<!--[if !supportLists]-->25.<!--[endif]-->    //此知识与[字符串比较]相同   

<!--[if !supportLists]-->26.<!--[endif]-->  

<!--[if !supportLists]-->27.<!--[endif]-->  5.小数转整数   

<!--[if !supportLists]-->28.<!--[endif]-->    var f = 1.5;   

<!--[if !supportLists]-->29.<!--[endif]-->    var i = Math.round(f);  //结果:2 (四舍五入)   

<!--[if !supportLists]-->30.<!--[endif]-->    var i = Math.ceil(f);   //结果:2 (返回大于f的最小整数)   

<!--[if !supportLists]-->31.<!--[endif]-->    var i = Math.floor(f);  //结果:1 (返回小于f的最大整数)   

<!--[if !supportLists]-->32.<!--[endif]-->  

<!--[if !supportLists]-->33.<!--[endif]-->  6.格式化显示数字   

<!--[if !supportLists]-->34.<!--[endif]-->    var i = 3.14159;   

<!--[if !supportLists]-->35.<!--[endif]-->      

<!--[if !supportLists]-->36.<!--[endif]-->    //格式化为两位小数的浮点数   

<!--[if !supportLists]-->37.<!--[endif]-->    var str = i.toFixed(2);     //结果: "3.14"   

<!--[if !supportLists]-->38.<!--[endif]-->      

<!--[if !supportLists]-->39.<!--[endif]-->    //格式化为五位数字的浮点数(从左到右五位数字,不够补零)   

<!--[if !supportLists]-->40.<!--[endif]-->    var str = i.toPrecision(5); //结果: "3.1415"   

<!--[if !supportLists]-->41.<!--[endif]-->  

<!--[if !supportLists]-->42.<!--[endif]-->  7.X进制数字的转换   

<!--[if !supportLists]-->43.<!--[endif]-->    //不是很懂 -.-   

<!--[if !supportLists]-->44.<!--[endif]-->    var i = parseInt("0x1f",16);   

<!--[if !supportLists]-->45.<!--[endif]-->    var i = parseInt(i,10);   

<!--[if !supportLists]-->46.<!--[endif]-->    var i = parseInt("11010011",2);   

<!--[if !supportLists]-->47.<!--[endif]-->  

<!--[if !supportLists]-->48.<!--[endif]-->  8.随机数   

<!--[if !supportLists]-->49.<!--[endif]-->    //返回0-1之间的任意小数   

<!--[if !supportLists]-->50.<!--[endif]-->    var rnd = Math.random();   

<!--[if !supportLists]-->51.<!--[endif]-->    //返回0-n之间的任意整数(不包括n)      

<!--[if !supportLists]-->52.<!--[endif]-->    var rnd = Math.floor(Math.random() * n) 

4.网上收藏的javascript堆栈

<!--[if !supportLists]-->1.  <!--[endif]-->function stack(){  

<!--[if !supportLists]-->2.  <!--[endif]-->      if(this.top==undefined){  

<!--[if !supportLists]-->3.  <!--[endif]-->      //初始化堆栈的顶部指针和数据存放域  

<!--[if !supportLists]-->4.  <!--[endif]-->            this.top=0;  

<!--[if !supportLists]-->5.  <!--[endif]-->            this.unit=new Array();  

<!--[if !supportLists]-->6.  <!--[endif]-->      }  

<!--[if !supportLists]-->7.  <!--[endif]-->      this.push=function(pushvalue){  

<!--[if !supportLists]-->8.  <!--[endif]-->      //定义压入堆栈的方法              

<!--[if !supportLists]-->9.  <!--[endif]-->            this.unit[this.top]=pushvalue;  

<!--[if !supportLists]-->10.<!--[endif]-->            this.top+=1;              

<!--[if !supportLists]-->11.<!--[endif]-->      }  

<!--[if !supportLists]-->12.<!--[endif]-->      this.readAllElements=function(){  

<!--[if !supportLists]-->13.<!--[endif]-->      //定义读取所有数据的方法  

<!--[if !supportLists]-->14.<!--[endif]-->            if(this.top==0){  

<!--[if !supportLists]-->15.<!--[endif]-->                  alert("当前栈空,无法读取数据");  

<!--[if !supportLists]-->16.<!--[endif]-->                  return("");  

<!--[if !supportLists]-->17.<!--[endif]-->            }  

<!--[if !supportLists]-->18.<!--[endif]-->            var count=0;  

<!--[if !supportLists]-->19.<!--[endif]-->            var outStr="";  

<!--[if !supportLists]-->20.<!--[endif]-->                          

<!--[if !supportLists]-->21.<!--[endif]-->            for(count=0;count<this.top;count++){  

<!--[if !supportLists]-->22.<!--[endif]-->                  outStr+=this.unit[count]+",";  

<!--[if !supportLists]-->23.<!--[endif]-->            }              

<!--[if !supportLists]-->24.<!--[endif]-->            return(outStr);  

<!--[if !supportLists]-->25.<!--[endif]-->      }  

<!--[if !supportLists]-->26.<!--[endif]-->      this.pop=function(){  

<!--[if !supportLists]-->27.<!--[endif]-->      //定义弹出堆栈的方法  

<!--[if !supportLists]-->28.<!--[endif]-->            if(this.top==0){  

<!--[if !supportLists]-->29.<!--[endif]-->                  alert("当前栈空,无法弹出数据");  

<!--[if !supportLists]-->30.<!--[endif]-->                  return("");  

<!--[if !supportLists]-->31.<!--[endif]-->            }  

<!--[if !supportLists]-->32.<!--[endif]-->            var      popTo=this.unit[this.top-1];  

<!--[if !supportLists]-->33.<!--[endif]-->            this.top--;  

<!--[if !supportLists]-->34.<!--[endif]-->            return(popTo);  

<!--[if !supportLists]-->35.<!--[endif]-->            /* 从堆栈弹出数据,顶部指针减一,不过这里没有做到资源的释放,也 

<!--[if !supportLists]-->36.<!--[endif]-->            就是说数据仍然存在于this.unit的数组中,只不过无法访问罢了。目前 

<!--[if !supportLists]-->37.<!--[endif]-->            我也没想到好的办法解决。*/  

<!--[if !supportLists]-->38.<!--[endif]-->      }  

<!--[if !supportLists]-->39.<!--[endif]-->}  

5.最常用的javascript日期函数

<!--[if !supportLists]-->1.  <!--[endif]-->·日期型(Date)   

<!--[if !supportLists]-->2.  <!--[endif]-->  1.声明   

<!--[if !supportLists]-->3.  <!--[endif]-->    var myDate = new Date();    //系统当前时间    

<!--[if !supportLists]-->4.  <!--[endif]-->    var myDate = new Date(yyyy, mm, dd, hh, mm, ss);   

<!--[if !supportLists]-->5.  <!--[endif]-->    var myDate = new Date(yyyy, mm, dd);   

<!--[if !supportLists]-->6.  <!--[endif]-->    var myDate = new Date("monthName dd, yyyy hh:mm:ss");   

<!--[if !supportLists]-->7.  <!--[endif]-->    var myDate = new Date("monthName dd, yyyy");   

<!--[if !supportLists]-->8.  <!--[endif]-->    var myDate = new Date(epochMilliseconds);   

<!--[if !supportLists]-->9.  <!--[endif]-->  

<!--[if !supportLists]-->10.<!--[endif]-->  2.获取时间的某部份   

<!--[if !supportLists]-->11.<!--[endif]-->    var myDate = new Date();   

<!--[if !supportLists]-->12.<!--[endif]-->    myDate.getYear();       //获取当前年份(2位)   

<!--[if !supportLists]-->13.<!--[endif]-->    myDate.getFullYear();   //获取完整的年份(4位,1970-????)   

<!--[if !supportLists]-->14.<!--[endif]-->    myDate.getMonth();      //获取当前月份(0-11,0代表1月)   

<!--[if !supportLists]-->15.<!--[endif]-->    myDate.getDate();       //获取当前日(1-31)   

<!--[if !supportLists]-->16.<!--[endif]-->    myDate.getDay();        //获取当前星期X(0-6,0代表星期天)     

<!--[if !supportLists]-->17.<!--[endif]-->    myDate.getTime();       //获取当前时间(从1970.1.1开始的毫秒数)   时间戳!!  

<!--[if !supportLists]-->18.<!--[endif]-->    myDate.getHours();      //获取当前小时数(0-23)   

<!--[if !supportLists]-->19.<!--[endif]-->    myDate.getMinutes();    //获取当前分钟数(0-59)   

<!--[if !supportLists]-->20.<!--[endif]-->    myDate.getSeconds();    //获取当前秒数(0-59)   

<!--[if !supportLists]-->21.<!--[endif]-->    myDate.getMilliseconds();   //获取当前毫秒数(0-999)   

<!--[if !supportLists]-->22.<!--[endif]-->    myDate.toLocaleDateString();    //获取当前日期   

<!--[if !supportLists]-->23.<!--[endif]-->    myDate.toLocaleTimeString();    //获取当前时间   

<!--[if !supportLists]-->24.<!--[endif]-->    myDate.toLocaleString( );       //获取日期与时间   

<!--[if !supportLists]-->25.<!--[endif]-->  

<!--[if !supportLists]-->26.<!--[endif]-->  3.计算之前或未来的时间   

<!--[if !supportLists]-->27.<!--[endif]-->    var myDate = new Date();   

<!--[if !supportLists]-->28.<!--[endif]-->    myDate.setDate(myDate.getDate() + 10);  //当前时间加10天   

<!--[if !supportLists]-->29.<!--[endif]-->    //类似的方法都基本相同,以set开头,具体参考第2点   

<!--[if !supportLists]-->30.<!--[endif]-->  

<!--[if !supportLists]-->31.<!--[endif]-->  4.计算两个日期的偏移量   

<!--[if !supportLists]-->32.<!--[endif]-->    var i = daysBetween(beginDate,endDate); //返回天数   

<!--[if !supportLists]-->33.<!--[endif]-->    var i = beginDate.getTimezoneOffset(endDate); //返回分钟数   

<!--[if !supportLists]-->34.<!--[endif]-->  

<!--[if !supportLists]-->35.<!--[endif]-->  5.检查有效日期   

<!--[if !supportLists]-->36.<!--[endif]-->    //checkDate() 只允许"mm-dd-yyyy"或"mm/dd/yyyy"两种格式的日期   

<!--[if !supportLists]-->37.<!--[endif]-->    if( checkDate("2006-01-01") ){ }   

<!--[if !supportLists]-->38.<!--[endif]-->      

<!--[if !supportLists]-->39.<!--[endif]-->    //正则表达式(自己写的检查 yyyy-mm-dd, yy-mm-dd, yyyy/mm/dd, yy/mm/dd 四种)   

<!--[if !supportLists]-->40.<!--[endif]-->    var r = /^(\d{2}|\d{4})[\/-]\d{1,2}[\/-]\d{1,2}$/;   

<!--[if !supportLists]-->41.<!--[endif]-->    if( r.test( myString ) ){ }  

6.最常用字符窜函数API

<!--[if !supportLists]-->1.  <!--[endif]-->·字符串(String)   

<!--[if !supportLists]-->2.  <!--[endif]-->  1.声明   

<!--[if !supportLists]-->3.  <!--[endif]-->    var myString = new String("Every good boy does fine.");   

<!--[if !supportLists]-->4.  <!--[endif]-->    var myString = "Every good boy does fine.";   

<!--[if !supportLists]-->5.  <!--[endif]-->  

<!--[if !supportLists]-->6.  <!--[endif]-->  2.字符串连接   

<!--[if !supportLists]-->7.  <!--[endif]-->    var myString = "Every " + "good boy " + "does fine.";   

<!--[if !supportLists]-->8.  <!--[endif]-->    var myString = "Every ";  myString += "good boy does fine.";   

<!--[if !supportLists]-->9.  <!--[endif]-->  

<!--[if !supportLists]-->10.<!--[endif]-->  3.截取字符串   

<!--[if !supportLists]-->11.<!--[endif]-->    //截取第 6 位开始的字符   

<!--[if !supportLists]-->12.<!--[endif]-->    var myString = "Every good boy does fine.";   

<!--[if !supportLists]-->13.<!--[endif]-->    var section = myString.substring(6);    //结果: "good boy does fine."   

<!--[if !supportLists]-->14.<!--[endif]-->      

<!--[if !supportLists]-->15.<!--[endif]-->    //截取第 0 位开始至第 10 位为止的字符   

<!--[if !supportLists]-->16.<!--[endif]-->    var myString = "Every good boy does fine.";   

<!--[if !supportLists]-->17.<!--[endif]-->    var section = myString.substring(0,10); //结果: "Every good"   

<!--[if !supportLists]-->18.<!--[endif]-->      

<!--[if !supportLists]-->19.<!--[endif]-->    //截取从第 11 位到倒数第 6 位为止的字符   

<!--[if !supportLists]-->20.<!--[endif]-->    var myString = "Every good boy does fine.";   

<!--[if !supportLists]-->21.<!--[endif]-->    var section = myString.slice(11,-6);    //结果: "boy does"   

<!--[if !supportLists]-->22.<!--[endif]-->      

<!--[if !supportLists]-->23.<!--[endif]-->    //从第 6 位开始截取长度为 4 的字符   

<!--[if !supportLists]-->24.<!--[endif]-->    var myString = "Every good boy does fine.";   

<!--[if !supportLists]-->25.<!--[endif]-->    var section = myString.substr(6,4);     //结果: "good"   

<!--[if !supportLists]-->26.<!--[endif]-->  

<!--[if !supportLists]-->27.<!--[endif]-->  4.转换大小写   

<!--[if !supportLists]-->28.<!--[endif]-->    var myString = "Hello";   

<!--[if !supportLists]-->29.<!--[endif]-->    var lcString = myString.toLowerCase();  //结果: "hello"   

<!--[if !supportLists]-->30.<!--[endif]-->    var ucString = myString.toUpperCase();  //结果: "HELLO"   

<!--[if !supportLists]-->31.<!--[endif]-->  

<!--[if !supportLists]-->32.<!--[endif]-->  5.字符串比较   

<!--[if !supportLists]-->33.<!--[endif]-->    var aString = "Hello!";   

<!--[if !supportLists]-->34.<!--[endif]-->    var bString = new String("Hello!");   

<!--[if !supportLists]-->35.<!--[endif]-->    if( aString == "Hello!" ){ }    //结果: true   

<!--[if !supportLists]-->36.<!--[endif]-->    if( aString == bString ){ }     //结果: true   

<!--[if !supportLists]-->37.<!--[endif]-->    if( aString === bString ){ }    //结果: false (两个对象不同,尽管它们的值相同)   

<!--[if !supportLists]-->38.<!--[endif]-->  

<!--[if !supportLists]-->39.<!--[endif]-->  6.检索字符串   

<!--[if !supportLists]-->40.<!--[endif]-->    var myString = "hello everybody.";   

<!--[if !supportLists]-->41.<!--[endif]-->    // 如果检索不到会返回-1,检索到的话返回在该串中的起始位置   

<!--[if !supportLists]-->42.<!--[endif]-->    if( myString.indexOf("every") > -1 ){ } //结果: true   

<!--[if !supportLists]-->43.<!--[endif]-->  

<!--[if !supportLists]-->44.<!--[endif]-->  7.查找替换字符串   

<!--[if !supportLists]-->45.<!--[endif]-->    var myString = "I is your father.";   

<!--[if !supportLists]-->46.<!--[endif]-->    var result = myString.replace("is","am");   //结果: "I am your father."   

<!--[if !supportLists]-->47.<!--[endif]-->  

<!--[if !supportLists]-->48.<!--[endif]-->  8.特殊字符:   

<!--[if !supportLists]-->49.<!--[endif]-->    \b : 后退符         \t : 水平制表符   

<!--[if !supportLists]-->50.<!--[endif]-->    \n : 换行符         \v : 垂直制表符   

<!--[if !supportLists]-->51.<!--[endif]-->    \f : 分页符         \r : 回车符   

<!--[if !supportLists]-->52.<!--[endif]-->    \" : 双引号         \' : 单引号   

<!--[if !supportLists]-->53.<!--[endif]-->    \\ : 反斜杆   

<!--[if !supportLists]-->54.<!--[endif]-->  

<!--[if !supportLists]-->55.<!--[endif]-->  9.将字符转换成Unicode编码   

<!--[if !supportLists]-->56.<!--[endif]-->    var myString = "hello";   

<!--[if !supportLists]-->57.<!--[endif]-->    var code = myString.charCodeAt(3);  //返回"l"的Unicode编码(整型)   

<!--[if !supportLists]-->58.<!--[endif]-->    var char = String.fromCharCode(66); //返回Unicode为66的字符   

<!--[if !supportLists]-->59.<!--[endif]-->  

<!--[if !supportLists]-->60.<!--[endif]-->  10.将字符串转换成URL编码   

<!--[if !supportLists]-->61.<!--[endif]-->    var myString = "hello all";   

<!--[if !supportLists]-->62.<!--[endif]-->    var code = encodeURI(myString);     //结果: "hello%20all"   

<!--[if !supportLists]-->63.<!--[endif]-->    var str = decodeURI(code);          //结果: "hello all"   

<!--[if !supportLists]-->64.<!--[endif]-->    //相应的还有:  encodeURIComponent()  decodeURIComponent() 

7.数字函数

<!--[if !supportLists]-->1.  <!--[endif]-->·Math对象   

<!--[if !supportLists]-->2.  <!--[endif]-->  1. Math.abs(num) : 返回num的绝对值   

<!--[if !supportLists]-->3.  <!--[endif]-->  2. Math.acos(num) : 返回num的反余弦值   

<!--[if !supportLists]-->4.  <!--[endif]-->  3. Math.asin(num) : 返回num的反正弦值   

<!--[if !supportLists]-->5.  <!--[endif]-->  4. Math.atan(num) : 返回num的反正切值   

<!--[if !supportLists]-->6.  <!--[endif]-->  5. Math.atan2(y,x) : 返回y除以x的商的反正切值   

<!--[if !supportLists]-->7.  <!--[endif]-->  6. Math.ceil(num) : 返回大于num的最小整数   

<!--[if !supportLists]-->8.  <!--[endif]-->  7. Math.cos(num) : 返回num的余弦值   

<!--[if !supportLists]-->9.  <!--[endif]-->  8. Math.exp(x) : 返回以自然数为底,x次幂的数   

<!--[if !supportLists]-->10.<!--[endif]-->  9. Math.floor(num) : 返回小于num的最大整数   

<!--[if !supportLists]-->11.<!--[endif]-->  10.Math.log(num) : 返回num的自然对数   

<!--[if !supportLists]-->12.<!--[endif]-->  11.Math.max(num1,num2) : 返回num1和num2中较大的一个   

<!--[if !supportLists]-->13.<!--[endif]-->  12.Math.min(num1,num2) : 返回num1和num2中较小的一个   

<!--[if !supportLists]-->14.<!--[endif]-->  13.Math.pow(x,y) : 返回x的y次方的值   

<!--[if !supportLists]-->15.<!--[endif]-->  14.Math.random() : 返回0到1之间的一个随机数   

<!--[if !supportLists]-->16.<!--[endif]-->  15.Math.round(num) : 返回num四舍五入后的值   

<!--[if !supportLists]-->17.<!--[endif]-->  16.Math.sin(num) : 返回num的正弦值   

<!--[if !supportLists]-->18.<!--[endif]-->  17.Math.sqrt(num) : 返回num的平方根   

<!--[if !supportLists]-->19.<!--[endif]-->  18.Math.tan(num) : 返回num的正切值   

<!--[if !supportLists]-->20.<!--[endif]-->  19.Math.E : 自然数(2.718281828459045)   

<!--[if !supportLists]-->21.<!--[endif]-->  20.Math.LN2 : 2的自然对数(0.6931471805599453)   

<!--[if !supportLists]-->22.<!--[endif]-->  21.Math.LN10 : 10的自然对数(2.302585092994046)   

<!--[if !supportLists]-->23.<!--[endif]-->  22.Math.LOG2E : log 2 为底的自然数(1.4426950408889634)   

<!--[if !supportLists]-->24.<!--[endif]-->  23.Math.LOG10E : log 10 为底的自然数(0.4342944819032518)   

<!--[if !supportLists]-->25.<!--[endif]-->  24.Math.PI : π(3.141592653589793)   

<!--[if !supportLists]-->26.<!--[endif]-->  25.Math.SQRT1_2 : 1/2的平方根(0.7071067811865476)   

<!--[if !supportLists]-->27.<!--[endif]-->  26.Math.SQRT2 : 2的平方根(1.4142135623730951)   

8.浏览器特征函数

<!--[if !supportLists]-->1.  <!--[endif]-->1.浏览器名称   

<!--[if !supportLists]-->2.  <!--[endif]-->   //IE : "Microsoft Internet Explorer"   

<!--[if !supportLists]-->3.  <!--[endif]-->   //NS : "Netscape"   

<!--[if !supportLists]-->4.  <!--[endif]-->   var browserName = navigator.appName;   

<!--[if !supportLists]-->5.  <!--[endif]-->  

<!--[if !supportLists]-->6.  <!--[endif]--> 2.浏览器版本   

<!--[if !supportLists]-->7.  <!--[endif]-->   bar browserVersion = navigator.appVersion;   

<!--[if !supportLists]-->8.  <!--[endif]-->  

<!--[if !supportLists]-->9.  <!--[endif]--> 3.客户端操作系统   

<!--[if !supportLists]-->10.<!--[endif]-->   var isWin = ( navigator.userAgent.indexOf("Win") != -1 );   

<!--[if !supportLists]-->11.<!--[endif]-->   var isMac = ( navigator.userAgent.indexOf("Mac") != -1 );   

<!--[if !supportLists]-->12.<!--[endif]-->   var isUnix = ( navigator.userAgent.indexOf("X11") != -1 );   

<!--[if !supportLists]-->13.<!--[endif]-->  

<!--[if !supportLists]-->14.<!--[endif]--> 4.判断是否支持某对象,方法,属性   

<!--[if !supportLists]-->15.<!--[endif]-->   //当一个对象,方法,属性未定义时会返回undefined或null等,这些特殊值都是false   

<!--[if !supportLists]-->16.<!--[endif]-->   if( document.images ){ }   

<!--[if !supportLists]-->17.<!--[endif]-->   if( document.getElementById ){ }   

<!--[if !supportLists]-->18.<!--[endif]-->  

<!--[if !supportLists]-->19.<!--[endif]--> 5.检查浏览器当前语言   

<!--[if !supportLists]-->20.<!--[endif]-->   if( navigator.userLanguage ){ var l = navigator.userLanguage.toUpperCase(); }   

<!--[if !supportLists]-->21.<!--[endif]-->  

<!--[if !supportLists]-->22.<!--[endif]--> 6.检查浏览器是否支持Cookies   

<!--[if !supportLists]-->23.<!--[endif]-->   if( navigator.cookieEnabled ){ }   

9.Javascript面向对象的方法实现继承:call方法

<!--[if !supportLists]-->1.  <!--[endif]-->// 动物类 animal  

<!--[if !supportLists]-->2.  <!--[endif]-->function animal(bSex){  

<!--[if !supportLists]-->3.  <!--[endif]-->    this.sex = bSex  

<!--[if !supportLists]-->4.  <!--[endif]-->    this.getSex = function(){  

<!--[if !supportLists]-->5.  <!--[endif]-->        return this.sex  

<!--[if !supportLists]-->6.  <!--[endif]-->    }  

<!--[if !supportLists]-->7.  <!--[endif]-->}  

<!--[if !supportLists]-->8.  <!--[endif]-->// 类静态变量 (如果你不修改它的话~~)  

<!--[if !supportLists]-->9.  <!--[endif]-->animal.SEX_G = new Object();    // 雌性  

<!--[if !supportLists]-->10.<!--[endif]-->animal.SEX_B = new Object();    // 雄性  

<!--[if !supportLists]-->11.<!--[endif]-->// 动物子类 鸟  

<!--[if !supportLists]-->12.<!--[endif]-->function bird(bSex){  

<!--[if !supportLists]-->13.<!--[endif]-->    animal.call(this, bSex);  

<!--[if !supportLists]-->14.<!--[endif]-->    this.fly = function(iSpeed){  

<!--[if !supportLists]-->15.<!--[endif]-->        alert("飞行时速高达 " + iSpeed);  

<!--[if !supportLists]-->16.<!--[endif]-->    }  

<!--[if !supportLists]-->17.<!--[endif]-->}  

<!--[if !supportLists]-->18.<!--[endif]-->// 动物子类 鱼  

<!--[if !supportLists]-->19.<!--[endif]-->function fish(bSex){  

<!--[if !supportLists]-->20.<!--[endif]-->    animal.call(this, bSex);  

<!--[if !supportLists]-->21.<!--[endif]-->    this.swim = function(iSpeed){  

<!--[if !supportLists]-->22.<!--[endif]-->        alert("游动时速高达 " + iSpeed)  

<!--[if !supportLists]-->23.<!--[endif]-->    }  

<!--[if !supportLists]-->24.<!--[endif]-->}  

<!--[if !supportLists]-->25.<!--[endif]-->// 鱼 鸟 杂交品种。。。  

<!--[if !supportLists]-->26.<!--[endif]-->function crossBF(bSex){  

<!--[if !supportLists]-->27.<!--[endif]-->    bird.call(this, bSex);  

<!--[if !supportLists]-->28.<!--[endif]-->    fish.call(this, bSex);  

<!--[if !supportLists]-->29.<!--[endif]-->}  

<!--[if !supportLists]-->30.<!--[endif]-->var oPet = new crossBF(animal.SEX_G);    // 雌性 鱼鸟  

<!--[if !supportLists]-->31.<!--[endif]-->    alert(oPet.getSex() == animal.SEX_G ? "雌性" : "雄性");  

<!--[if !supportLists]-->32.<!--[endif]-->    oPet.fly(124)  

<!--[if !supportLists]-->33.<!--[endif]-->    oPet.swim(254)  

10.用面向对象的编程方式写javascript

<!--[if !supportLists]-->1.  <!--[endif]-->MyTool = new function(){  

<!--[if !supportLists]-->2.  <!--[endif]-->        /** 

<!--[if !supportLists]-->3.  <!--[endif]-->         * 返回非空字符串,如果有默认值就返回默认字符串. 

<!--[if !supportLists]-->4.  <!--[endif]-->         */  

<!--[if !supportLists]-->5.  <!--[endif]-->        this.notNull = function(str,defaultStr){  

<!--[if !supportLists]-->6.  <!--[endif]-->                if(typeof(str)=="undefined"||str==null||str==''){  

<!--[if !supportLists]-->7.  <!--[endif]-->                        if(defaultStr)  

<!--[if !supportLists]-->8.  <!--[endif]-->                                return defaultStr;  

<!--[if !supportLists]-->9.  <!--[endif]-->                        else  

<!--[if !supportLists]-->10.<!--[endif]-->                                return '';  

<!--[if !supportLists]-->11.<!--[endif]-->                }  

<!--[if !supportLists]-->12.<!--[endif]-->                else{  

<!--[if !supportLists]-->13.<!--[endif]-->                        return str;  

<!--[if !supportLists]-->14.<!--[endif]-->                }  

<!--[if !supportLists]-->15.<!--[endif]-->        }  

<!--[if !supportLists]-->16.<!--[endif]-->}  

<!--[if !supportLists]-->17.<!--[endif]-->  

<!--[if !supportLists]-->18.<!--[endif]-->rootId = MyTool.notNull(rootId,'001000');    

11.常用的js方法,包括表单校验的一些方法,下拉菜单常用的方法等等:

<!--[if !supportLists]-->1.  <!--[endif]-->/** 

<!--[if !supportLists]-->2.  <!--[endif]--> * 对JSON对象转换为字符串. 

<!--[if !supportLists]-->3.  <!--[endif]--> * @param {json对象} json 

<!--[if !supportLists]-->4.  <!--[endif]--> * @return {json字符串} 

<!--[if !supportLists]-->5.  <!--[endif]--> */  

<!--[if !supportLists]-->6.  <!--[endif]-->function jsonObj2Str(json) {  

<!--[if !supportLists]-->7.  <!--[endif]-->        var str = "{";  

<!--[if !supportLists]-->8.  <!--[endif]-->        for (prop in json) {  

<!--[if !supportLists]-->9.  <!--[endif]-->                str += prop + ":" + json[prop] + ",";  

<!--[if !supportLists]-->10.<!--[endif]-->        }  

<!--[if !supportLists]-->11.<!--[endif]-->        str = str.substr(0, str.length - 1);  

<!--[if !supportLists]-->12.<!--[endif]-->        str += "}";   

<!--[if !supportLists]-->13.<!--[endif]-->        return str;  

<!--[if !supportLists]-->14.<!--[endif]-->}  

<!--[if !supportLists]-->15.<!--[endif]-->  

<!--[if !supportLists]-->16.<!--[endif]-->/** 

<!--[if !supportLists]-->17.<!--[endif]--> * 将json字符串转换为json对象. 

<!--[if !supportLists]-->18.<!--[endif]--> * @param {json字符串} jsonstr 

<!--[if !supportLists]-->19.<!--[endif]--> * @return {json对象} 

<!--[if !supportLists]-->20.<!--[endif]--> */  

<!--[if !supportLists]-->21.<!--[endif]-->function jsonStr2Obj(jsonstr) {  

<!--[if !supportLists]-->22.<!--[endif]-->         return eval("("+jsonstr+")");  

<!--[if !supportLists]-->23.<!--[endif]-->}  

<!--[if !supportLists]-->24.<!--[endif]-->  

<!--[if !supportLists]-->25.<!--[endif]-->/** 

<!--[if !supportLists]-->26.<!--[endif]--> * 得到一个元素的left坐标值. 

<!--[if !supportLists]-->27.<!--[endif]--> * @param {dom对象} obj 

<!--[if !supportLists]-->28.<!--[endif]--> * @return {位置值} 

<!--[if !supportLists]-->29.<!--[endif]--> */  

<!--[if !supportLists]-->30.<!--[endif]-->function getLeft(obj){   

<!--[if !supportLists]-->31.<!--[endif]-->        var offset=e.offsetLeft;   

<!--[if !supportLists]-->32.<!--[endif]-->        if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);   

<!--[if !supportLists]-->33.<!--[endif]-->        return offset;   

<!--[if !supportLists]-->34.<!--[endif]-->}   

<!--[if !supportLists]-->35.<!--[endif]-->  

<!--[if !supportLists]-->36.<!--[endif]-->/** 

<!--[if !supportLists]-->37.<!--[endif]--> * 得到一个元素的绝对位置的top坐标值. 

<!--[if !supportLists]-->38.<!--[endif]--> * @param {dom对象} obj 

<!--[if !supportLists]-->39.<!--[endif]--> * @return {位置值} 

<!--[if !supportLists]-->40.<!--[endif]--> */  

<!--[if !supportLists]-->41.<!--[endif]-->function getTop(obj){   

<!--[if !supportLists]-->42.<!--[endif]-->        var offset=e.offsetTop;   

<!--[if !supportLists]-->43.<!--[endif]-->        if(e.offsetParent!=null) offset+=getTop(e.offsetParent);   

<!--[if !supportLists]-->44.<!--[endif]-->        return offset;   

<!--[if !supportLists]-->45.<!--[endif]-->}   

<!--[if !supportLists]-->46.<!--[endif]-->  

<!--[if !supportLists]-->47.<!--[endif]-->/** 

<!--[if !supportLists]-->48.<!--[endif]--> * 删除一个字符串的左右空格. 

<!--[if !supportLists]-->49.<!--[endif]--> * @param {原始字符串} str 

<!--[if !supportLists]-->50.<!--[endif]--> * @return {删除空格之后的字符串} 

<!--[if !supportLists]-->51.<!--[endif]--> */  

<!--[if !supportLists]-->52.<!--[endif]-->function  trim(str)  

<!--[if !supportLists]-->53.<!--[endif]-->{    

<!--[if !supportLists]-->54.<!--[endif]-->   return  str.replace(/(^\s*)|(\s*$)/g,"");    

<!--[if !supportLists]-->55.<!--[endif]-->}  

<!--[if !supportLists]-->56.<!--[endif]-->  

<!--[if !supportLists]-->57.<!--[endif]-->/** 

<!--[if !supportLists]-->58.<!--[endif]--> * 根据id取出一个元素. 

<!--[if !supportLists]-->59.<!--[endif]--> * @param {元素id值} str 

<!--[if !supportLists]-->60.<!--[endif]--> * @return {dom对象} 

<!--[if !supportLists]-->61.<!--[endif]--> */  

<!--[if !supportLists]-->62.<!--[endif]-->function $(str) {  

<!--[if !supportLists]-->63.<!--[endif]-->        return document.getElementById(str);  

<!--[if !supportLists]-->64.<!--[endif]-->}  

<!--[if !supportLists]-->65.<!--[endif]-->  

<!--[if !supportLists]-->66.<!--[endif]-->/** 

<!--[if !supportLists]-->67.<!--[endif]--> * 按name获取一个对象. 

<!--[if !supportLists]-->68.<!--[endif]--> * @param {元素name值} str 

<!--[if !supportLists]-->69.<!--[endif]--> * @return {根据name返回的第一个对象} 

<!--[if !supportLists]-->70.<!--[endif]--> */  

<!--[if !supportLists]-->71.<!--[endif]-->function $byName(str) {  

<!--[if !supportLists]-->72.<!--[endif]-->        var arr = document.getElementsByName(str);  

<!--[if !supportLists]-->73.<!--[endif]-->        if (arr)  

<!--[if !supportLists]-->74.<!--[endif]-->                return arr[0];  

<!--[if !supportLists]-->75.<!--[endif]-->        else  

<!--[if !supportLists]-->76.<!--[endif]-->                return null;  

<!--[if !supportLists]-->77.<!--[endif]-->}  

<!--[if !supportLists]-->78.<!--[endif]-->  

<!--[if !supportLists]-->79.<!--[endif]-->/***************以下方法和表单验证相关*************************************************/  

<!--[if !supportLists]-->80.<!--[endif]-->/** 

<!--[if !supportLists]-->81.<!--[endif]--> * 返回非空字符串,如果有默认值就返回默认字符串. 

<!--[if !supportLists]-->82.<!--[endif]--> * @param {要进行转换的原字符串} str 

<!--[if !supportLists]-->83.<!--[endif]--> * @param {默认值} defaultStr 

<!--[if !supportLists]-->84.<!--[endif]--> * @return {返回结果} 

<!--[if !supportLists]-->85.<!--[endif]--> */  

<!--[if !supportLists]-->86.<!--[endif]-->function notNull(str, defaultStr) {  

<!--[if !supportLists]-->87.<!--[endif]-->        if (typeof(str) == "undefined" || str == null || str == '') {  

<!--[if !supportLists]-->88.<!--[endif]-->                if (defaultStr)  

<!--[if !supportLists]-->89.<!--[endif]-->                        return defaultStr;  

<!--[if !supportLists]-->90.<!--[endif]-->                else  

<!--[if !supportLists]-->91.<!--[endif]-->                        return '';  

<!--[if !supportLists]-->92.<!--[endif]-->        } else {  

<!--[if !supportLists]-->93.<!--[endif]-->                return str;  

<!--[if !supportLists]-->94.<!--[endif]-->        }  

<!--[if !supportLists]-->95.<!--[endif]-->}    

<!--[if !supportLists]-->96.<!--[endif]-->  

<!--[if !supportLists]-->97.<!--[endif]-->/** 

<!--[if !supportLists]-->98.<!--[endif]--> * 比较两个日期大小. 

<!--[if !supportLists]-->99.<!--[endif]--> * @param {较小日期的文本框id} smallDate 

<!--[if !supportLists]-->100.  <!--[endif]--> * @param {较大日期的文本框id} bigDate 

<!--[if !supportLists]-->101.  <!--[endif]--> * @param {出错的提示信息} msg 

<!--[if !supportLists]-->102.  <!--[endif]--> */  

<!--[if !supportLists]-->103.  <!--[endif]-->function compareTwoDate(smallDate, bigDate, msg) {  

<!--[if !supportLists]-->104.  <!--[endif]-->        var v1 = $(smallDate).value;  

<!--[if !supportLists]-->105.  <!--[endif]-->        var v2 = $(bigDate).value;  

<!--[if !supportLists]-->106.  <!--[endif]-->        if (v1 >= v2) {  

<!--[if !supportLists]-->107.  <!--[endif]-->                alert(msg);  

<!--[if !supportLists]-->108.  <!--[endif]-->                                v2.focus();  

<!--[if !supportLists]-->109.  <!--[endif]-->                return false;  

<!--[if !supportLists]-->110.  <!--[endif]-->        }  

<!--[if !supportLists]-->111.  <!--[endif]-->        return true;  

<!--[if !supportLists]-->112.  <!--[endif]-->}  

<!--[if !supportLists]-->113.  <!--[endif]-->  

<!--[if !supportLists]-->114.  <!--[endif]-->/** 

<!--[if !supportLists]-->115.  <!--[endif]--> * 比较两个金额大小的方法. 

<!--[if !supportLists]-->116.  <!--[endif]--> * @param {较小的金额} smallNum 

<!--[if !supportLists]-->117.  <!--[endif]--> * @param {较大的金额} bigNum 

<!--[if !supportLists]-->118.  <!--[endif]--> * @param {出错提示信息} msg 

<!--[if !supportLists]-->119.  <!--[endif]--> * @return {Boolean} 

<!--[if !supportLists]-->120.  <!--[endif]--> */  

<!--[if !supportLists]-->121.  <!--[endif]-->function compareTwoNum(smallNum, bigNum, msg) {  

<!--[if !supportLists]-->122.  <!--[endif]-->        var v1 = $(smallNum).value;  

<!--[if !supportLists]-->123.  <!--[endif]-->        var v2 = $(bigNum).value;   

<!--[if !supportLists]-->124.  <!--[endif]-->        if (parseFloat(v1) >= parseFloat(v2)) {  

<!--[if !supportLists]-->125.  <!--[endif]-->                alert(msg);  

<!--[if !supportLists]-->126.  <!--[endif]-->                                v2.focus();  

<!--[if !supportLists]-->127.  <!--[endif]-->                return false;  

<!--[if !supportLists]-->128.  <!--[endif]-->        }  

<!--[if !supportLists]-->129.  <!--[endif]-->        return true;  

<!--[if !supportLists]-->130.  <!--[endif]-->}  

<!--[if !supportLists]-->131.  <!--[endif]-->  

<!--[if !supportLists]-->132.  <!--[endif]-->/** 

<!--[if !supportLists]-->133.  <!--[endif]--> * 检查文本框的长度是否超出指定长度. 

<!--[if !supportLists]-->134.  <!--[endif]--> * @param {文本id} textId 

<!--[if !supportLists]-->135.  <!--[endif]--> * @param {文本框的最大长度} len 

<!--[if !supportLists]-->136.  <!--[endif]--> * @param {文本框描述内容} msg 

<!--[if !supportLists]-->137.  <!--[endif]--> * @return {有错就返回false,否则返回true} 

<!--[if !supportLists]-->138.  <!--[endif]--> */  

<!--[if !supportLists]-->139.  <!--[endif]-->function checkLength(textId, len, msg) {  

<!--[if !supportLists]-->140.  <!--[endif]-->        obj = $(textId);  

<!--[if !supportLists]-->141.  <!--[endif]-->        str = obj.value;  

<!--[if !supportLists]-->142.  <!--[endif]-->        str = str.replace(/[^\x00-\xff]/g, "**");  

<!--[if !supportLists]-->143.  <!--[endif]-->        realLen = str.length;  

<!--[if !supportLists]-->144.  <!--[endif]-->        if (realLen > len) {  

<!--[if !supportLists]-->145.  <!--[endif]-->                alert("[" + msg + "]" + "长度最大为" + len + "位," + "请重新输入!\n注意:一个汉字占2位。");  

<!--[if !supportLists]-->146.  <!--[endif]-->                obj.focus();  

<!--[if !supportLists]-->147.  <!--[endif]-->                return false;  

<!--[if !supportLists]-->148.  <!--[endif]-->        } else  

<!--[if !supportLists]-->149.  <!--[endif]-->                return true;  

<!--[if !supportLists]-->150.  <!--[endif]-->}  

<!--[if !supportLists]-->151.  <!--[endif]-->  

<!--[if !supportLists]-->152.  <!--[endif]-->/** 

<!--[if !supportLists]-->153.  <!--[endif]--> * 判断某个文本框不可以为空. 

<!--[if !supportLists]-->154.  <!--[endif]--> * @param {文本框id} textId 

<!--[if !supportLists]-->155.  <!--[endif]--> * @param {文本框描述内容} msg 

<!--[if !supportLists]-->156.  <!--[endif]--> * @return {有错就返回false,否则返回true} 

<!--[if !supportLists]-->157.  <!--[endif]--> */  

<!--[if !supportLists]-->158.  <!--[endif]-->function checkIfEmpty(textId, msg) {  

<!--[if !supportLists]-->159.  <!--[endif]-->        var textObj = $(textId);  

<!--[if !supportLists]-->160.  <!--[endif]-->        var textValue = textObj.value;  

<!--[if !supportLists]-->161.  <!--[endif]-->        if (trim(textValue) == '') {  

<!--[if !supportLists]-->162.  <!--[endif]-->                alert('[' + msg + ']不得为空!');  

<!--[if !supportLists]-->163.  <!--[endif]-->                textObj.focus();  

<!--[if !supportLists]-->164.  <!--[endif]-->                return false;  

<!--[if !supportLists]-->165.  <!--[endif]-->        } else {  

<!--[if !supportLists]-->166.  <!--[endif]-->                return true;  

<!--[if !supportLists]-->167.  <!--[endif]-->        }  

<!--[if !supportLists]-->168.  <!--[endif]-->}  

<!--[if !supportLists]-->169.  <!--[endif]-->  

<!--[if !supportLists]-->170.  <!--[endif]-->/** 

<!--[if !supportLists]-->171.  <!--[endif]--> * 判断指定文本框内容必须为邮件. 

<!--[if !supportLists]-->172.  <!--[endif]--> * @param {文本框id} textId 

<!--[if !supportLists]-->173.  <!--[endif]--> * @param {文本框描述} msg 

<!--[if !supportLists]-->174.  <!--[endif]--> * @return {如果是邮件内容就返回true否则返回false} 

<!--[if !supportLists]-->175.  <!--[endif]--> */  

<!--[if !supportLists]-->176.  <!--[endif]-->function checkIsMail(textId, msg) {  

<!--[if !supportLists]-->177.  <!--[endif]-->        var obj = $(textId);  

<!--[if !supportLists]-->178.  <!--[endif]-->        if (!_isEmail(obj.value)) {  

<!--[if !supportLists]-->179.  <!--[endif]-->                alert('[' + msg + ']不是合法的邮件地址!');  

<!--[if !supportLists]-->180.  <!--[endif]-->                obj.focus();  

<!--[if !supportLists]-->181.  <!--[endif]-->                return false;  

<!--[if !supportLists]-->182.  <!--[endif]-->        } else  

<!--[if !supportLists]-->183.  <!--[endif]-->                return true;  

<!--[if !supportLists]-->184.  <!--[endif]-->}  

<!--[if !supportLists]-->185.  <!--[endif]-->  

<!--[if !supportLists]-->186.  <!--[endif]-->/** 

<!--[if !supportLists]-->187.  <!--[endif]--> * 验证是不是邮件. 

<!--[if !supportLists]-->188.  <!--[endif]--> * @param {要验证的字符串} strEmail 

<!--[if !supportLists]-->189.  <!--[endif]--> * @return {Boolean} 

<!--[if !supportLists]-->190.  <!--[endif]--> */  

<!--[if !supportLists]-->191.  <!--[endif]-->function _isEmail(strEmail) {  

<!--[if !supportLists]-->192.  <!--[endif]-->        //接下来的验证是否有两个以上的‘.’号,有的话就是错的!  

<!--[if !supportLists]-->193.  <!--[endif]-->        var first = strEmail.indexOf('.');    

<!--[if !supportLists]-->194.  <!--[endif]-->        if (strEmail.indexOf('@')== -1) {  

<!--[if !supportLists]-->195.  <!--[endif]-->                return false;  

<!--[if !supportLists]-->196.  <!--[endif]-->        }  

<!--[if !supportLists]-->197.  <!--[endif]-->        var tempStr = strEmail.substring(first + 1);  

<!--[if !supportLists]-->198.  <!--[endif]-->         if (tempStr.indexOf('.') != -1) {  

<!--[if !supportLists]-->199.  <!--[endif]-->                return false;  

<!--[if !supportLists]-->200.  <!--[endif]-->        }  

<!--[if !supportLists]-->201.  <!--[endif]-->        if (strEmail  

<!--[if !supportLists]-->202.  <!--[endif]-->                        .search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {  

<!--[if !supportLists]-->203.  <!--[endif]-->                return true;  

<!--[if !supportLists]-->204.  <!--[endif]-->        } else  

<!--[if !supportLists]-->205.  <!--[endif]-->                return false;  

<!--[if !supportLists]-->206.  <!--[endif]-->}  

<!--[if !supportLists]-->207.  <!--[endif]-->  

<!--[if !supportLists]-->208.  <!--[endif]-->/** 

<!--[if !supportLists]-->209.  <!--[endif]--> * 判断某个文本框是否数字. 

<!--[if !supportLists]-->210.  <!--[endif]--> * @param {文本框id} textId 

<!--[if !supportLists]-->211.  <!--[endif]--> * @param {文本框描述内容} msg 

<!--[if !supportLists]-->212.  <!--[endif]--> * @return {Boolean} 

<!--[if !supportLists]-->213.  <!--[endif]--> */  

<!--[if !supportLists]-->214.  <!--[endif]-->function checkIsNum(textId, msg) {  

<!--[if !supportLists]-->215.  <!--[endif]-->        obj = $(textId);  

<!--[if !supportLists]-->216.  <!--[endif]-->        if (isNaN(obj.value)) {  

<!--[if !supportLists]-->217.  <!--[endif]-->                alert('[' + msg + ']必须为数字。');  

<!--[if !supportLists]-->218.  <!--[endif]-->                obj.focus();  

<!--[if !supportLists]-->219.  <!--[endif]-->                return false;  

<!--[if !supportLists]-->220.  <!--[endif]-->        } else  

<!--[if !supportLists]-->221.  <!--[endif]-->                return true;  

<!--[if !supportLists]-->222.  <!--[endif]-->}  

<!--[if !supportLists]-->223.  <!--[endif]-->  

<!--[if !supportLists]-->224.  <!--[endif]-->/** 

<!--[if !supportLists]-->225.  <!--[endif]--> * 判断某个文本框是否含有非法字符. 

<!--[if !supportLists]-->226.  <!--[endif]--> * @param {文本框的id} textId 

<!--[if !supportLists]-->227.  <!--[endif]--> * @param {文本框描述内容} msg 

<!--[if !supportLists]-->228.  <!--[endif]--> * @return {有错就返回false否则返回true} 

<!--[if !supportLists]-->229.  <!--[endif]--> */  

<!--[if !supportLists]-->230.  <!--[endif]-->function checkIsValid(textId, msg) {  

<!--[if !supportLists]-->231.  <!--[endif]-->        obj = $(textId);  

<!--[if !supportLists]-->232.  <!--[endif]-->        if (!_isValidString(obj.value, '[' + msg + ']不得含有非法字符。')) {  

<!--[if !supportLists]-->233.  <!--[endif]-->                obj.focus();  

<!--[if !supportLists]-->234.  <!--[endif]-->                return false;  

<!--[if !supportLists]-->235.  <!--[endif]-->        }  

<!--[if !supportLists]-->236.  <!--[endif]-->        return true;  

<!--[if !supportLists]-->237.  <!--[endif]-->}  

<!--[if !supportLists]-->238.  <!--[endif]-->  

<!--[if !supportLists]-->239.  <!--[endif]-->/** 

<!--[if !supportLists]-->240.  <!--[endif]--> * 判断是不是合法字符串. 

<!--[if !supportLists]-->241.  <!--[endif]--> * @param {要进行判断的字符串} szStr 

<!--[if !supportLists]-->242.  <!--[endif]--> * @param {文本描述} errMsg  

<!--[if !supportLists]-->243.  <!--[endif]--> * @return {合法则返回true否则返回false} 

<!--[if !supportLists]-->244.  <!--[endif]--> */  

<!--[if !supportLists]-->245.  <!--[endif]-->function _isValidString(szStr,errMsg) {  

<!--[if !supportLists]-->246.  <!--[endif]-->        voidChar = "'\"><`~!@#$%^&\(\)()!¥……??“”‘’*";  

<!--[if !supportLists]-->247.  <!--[endif]-->        for (var i = 0; i < voidChar.length; i++) {  

<!--[if !supportLists]-->248.  <!--[endif]-->                aChar = voidChar.substring(i, i + 1);  

<!--[if !supportLists]-->249.  <!--[endif]-->                if (szStr.indexOf(aChar) > -1){  

<!--[if !supportLists]-->250.  <!--[endif]-->                        alert(errMsg)  

<!--[if !supportLists]-->251.  <!--[endif]-->                        return false;  

<!--[if !supportLists]-->252.  <!--[endif]-->                }  

<!--[if !supportLists]-->253.  <!--[endif]-->        }  

<!--[if !supportLists]-->254.  <!--[endif]-->        return true;  

<!--[if !supportLists]-->255.  <!--[endif]-->}   

<!--[if !supportLists]-->256.  <!--[endif]-->  

<!--[if !supportLists]-->257.  <!--[endif]-->/*************** 以下方法和下拉菜单相关*************************************************/  

<!--[if !supportLists]-->258.  <!--[endif]-->/** 

<!--[if !supportLists]-->259.  <!--[endif]--> * 控制下拉菜单不可以为-1(未选择情况value=-1) 

<!--[if !supportLists]-->260.  <!--[endif]--> * @param {下拉菜单id} selectId 

<!--[if !supportLists]-->261.  <!--[endif]--> * @param {下拉菜单描述内容} msg 

<!--[if !supportLists]-->262.  <!--[endif]--> * @param {下拉菜单的空值对应的value,默认为-1} nullValue 

<!--[if !supportLists]-->263.  <!--[endif]--> * @return {Boolean} 

<!--[if !supportLists]-->264.  <!--[endif]--> */  

<!--[if !supportLists]-->265.  <!--[endif]-->function checkChooseSelect(selectId, msg ,nullValue) {  

<!--[if !supportLists]-->266.  <!--[endif]-->        var obj = $(selectId);   

<!--[if !supportLists]-->267.  <!--[endif]-->        if (obj.value == notNull(nullValue,'-1')) {  

<!--[if !supportLists]-->268.  <!--[endif]-->                alert('[' + msg + ']必选!');  

<!--[if !supportLists]-->269.  <!--[endif]-->                obj.focus();  

<!--[if !supportLists]-->270.  <!--[endif]-->                return false;  

<!--[if !supportLists]-->271.  <!--[endif]-->        } else  

<!--[if !supportLists]-->272.  <!--[endif]-->                return true;  

<!--[if !supportLists]-->273.  <!--[endif]-->}  

<!--[if !supportLists]-->274.  <!--[endif]-->  

<!--[if !supportLists]-->275.  <!--[endif]-->/** 

<!--[if !supportLists]-->276.  <!--[endif]--> * 得到下拉菜单的显示的文字. 

<!--[if !supportLists]-->277.  <!--[endif]--> * @param {下拉菜单dom对象} selectObj 

<!--[if !supportLists]-->278.  <!--[endif]--> * @return {返回下拉菜单的显示的"文本"} 

<!--[if !supportLists]-->279.  <!--[endif]--> */  

<!--[if !supportLists]-->280.  <!--[endif]-->function getSelectText(selectObj) {  

<!--[if !supportLists]-->281.  <!--[endif]-->       return selectObj.options[selectObj.selectedIndex].text;  

<!--[if !supportLists]-->282.  <!--[endif]-->}  

<!--[if !supportLists]-->283.  <!--[endif]-->  

<!--[if !supportLists]-->284.  <!--[endif]-->/** 

<!--[if !supportLists]-->285.  <!--[endif]--> * 得到下拉菜单的显示的值. 

<!--[if !supportLists]-->286.  <!--[endif]--> * @param {下拉菜单dom对象} selectObj 

<!--[if !supportLists]-->287.  <!--[endif]--> * @return {得到下拉菜单的显示的"值"} 

<!--[if !supportLists]-->288.  <!--[endif]--> */  

<!--[if !supportLists]-->289.  <!--[endif]-->function getSelectValue(selectObj) {  

<!--[if !supportLists]-->290.  <!--[endif]-->        return selectObj.options[selectObj.selectedIndex].value;  

<!--[if !supportLists]-->291.  <!--[endif]-->}  

<!--[if !supportLists]-->292.  <!--[endif]-->  

<!--[if !supportLists]-->293.  <!--[endif]-->/** 

<!--[if !supportLists]-->294.  <!--[endif]--> * 设置下拉菜单的选择状态到指定的值. 

<!--[if !supportLists]-->295.  <!--[endif]--> * @param {下拉菜单对象} obj 

<!--[if !supportLists]-->296.  <!--[endif]--> * @param {要选择的值} value 

<!--[if !supportLists]-->297.  <!--[endif]--> */  

<!--[if !supportLists]-->298.  <!--[endif]-->function setSelectValue(obj, value) {  

<!--[if !supportLists]-->299.  <!--[endif]-->        /*for (i = obj.options.length - 1; i >= 0; i--) { 

<!--[if !supportLists]-->300.  <!--[endif]-->                if (obj.options[i].value == value) { 

<!--[if !supportLists]-->301.  <!--[endif]-->                        obj.options[i].selected = true; 

<!--[if !supportLists]-->302.  <!--[endif]-->                        return; 

<!--[if !supportLists]-->303.  <!--[endif]-->                } 

<!--[if !supportLists]-->304.  <!--[endif]-->        } 

<!--[if !supportLists]-->305.  <!--[endif]-->*/  

<!--[if !supportLists]-->306.  <!--[endif]-->      obj.value= value;  

<!--[if !supportLists]-->307.  <!--[endif]-->}  

<!--[if !supportLists]-->308.  <!--[endif]-->  

<!--[if !supportLists]-->309.  <!--[endif]-->/** 

<!--[if !supportLists]-->310.  <!--[endif]--> * 根据键值串的内容进行下拉菜单的动态组装 

<!--[if !supportLists]-->311.  <!--[endif]--> * @param {要进行下拉菜单组装的dom对象} obj 

<!--[if !supportLists]-->312.  <!--[endif]--> * @param {键值对用,和;分割,例如'1,男;2,女;3,未知'} valAndText 

<!--[if !supportLists]-->313.  <!--[endif]--> */  

<!--[if !supportLists]-->314.  <!--[endif]-->function setSelectContent(obj,valAndText){  

<!--[if !supportLists]-->315.  <!--[endif]-->        if(trim(valAndText)==''){  

<!--[if !supportLists]-->316.  <!--[endif]-->                alert('没有要进行组装下拉菜单的数据!');  

<!--[if !supportLists]-->317.  <!--[endif]-->                return false;                  

<!--[if !supportLists]-->318.  <!--[endif]-->        }  

<!--[if !supportLists]-->319.  <!--[endif]-->        clearSelect(obj);  

<!--[if !supportLists]-->320.  <!--[endif]-->        var keyandvalues = valAndText.split(';');  

<!--[if !supportLists]-->321.  <!--[endif]-->        for(var i=0;i<keyandvalues.length;i++){  

<!--[if !supportLists]-->322.  <!--[endif]-->                var arr = keyandvalues[i].split(',');  

<!--[if !supportLists]-->323.  <!--[endif]-->                if(arr){  

<!--[if !supportLists]-->324.  <!--[endif]-->                        var value =arr[0];   

<!--[if !supportLists]-->325.  <!--[endif]-->                        var text =arr[1];   

<!--[if !supportLists]-->326.  <!--[endif]-->                        var objOption = new Option(text,value);  

<!--[if !supportLists]-->327.  <!--[endif]-->                        obj.add(objOption);  

<!--[if !supportLists]-->328.  <!--[endif]-->                }  

<!--[if !supportLists]-->329.  <!--[endif]-->        }  

<!--[if !supportLists]-->330.  <!--[endif]-->}  

<!--[if !supportLists]-->331.  <!--[endif]-->  

<!--[if !supportLists]-->332.  <!--[endif]-->/** 

<!--[if !supportLists]-->333.  <!--[endif]--> * 清空下拉菜单里面的内容. 

<!--[if !supportLists]-->334.  <!--[endif]--> * @param {下拉菜单对象} obj 

<!--[if !supportLists]-->335.  <!--[endif]--> */  

<!--[if !supportLists]-->336.  <!--[endif]-->function clearSelect(obj) {   

<!--[if !supportLists]-->337.  <!--[endif]-->    for (var i=obj.options.length; i >0; i--) {  

<!--[if !supportLists]-->338.  <!--[endif]-->        obj.remove(0);   

<!--[if !supportLists]-->339.  <!--[endif]-->    }          

<!--[if !supportLists]-->340.  <!--[endif]-->}   

<!--[if !supportLists]-->341.  <!--[endif]-->  

<!--[if !supportLists]-->342.  <!--[endif]-->/*************** 以下方法和多选框相关*************************************************/  

<!--[if !supportLists]-->343.  <!--[endif]-->/** 

<!--[if !supportLists]-->344.  <!--[endif]--> * 返回选中的checks的id组成的字符串,逗号隔开. 

<!--[if !supportLists]-->345.  <!--[endif]--> * @param {checks数组} checks 

<!--[if !supportLists]-->346.  <!--[endif]--> * @return 选择的id组成的字符串 

<!--[if !supportLists]-->347.  <!--[endif]--> */  

<!--[if !supportLists]-->348.  <!--[endif]-->function getCheckedIds(checks){  

<!--[if !supportLists]-->349.  <!--[endif]-->        var selectedValue = '';  

<!--[if !supportLists]-->350.  <!--[endif]-->        var len = checks.length;  

<!--[if !supportLists]-->351.  <!--[endif]-->        for(var index=0; index<len; index++) {  

<!--[if !supportLists]-->352.  <!--[endif]-->        if(checks[index].checked==true) {  

<!--[if !supportLists]-->353.  <!--[endif]-->            selectedValue +=  checks[index].value+",";   

<!--[if !supportLists]-->354.  <!--[endif]-->        }  

<!--[if !supportLists]-->355.  <!--[endif]-->    }  

<!--[if !supportLists]-->356.  <!--[endif]-->        if(selectedValue.length>0)  

<!--[if !supportLists]-->357.  <!--[endif]-->                return selectedValue.substring(0,selectedValue.length-1);  

<!--[if !supportLists]-->358.  <!--[endif]-->    return selectedValue;  

<!--[if !supportLists]-->359.  <!--[endif]-->}  

    校验以上JS,代入html进行测试

<!--[if !supportLists]-->1.  <!--[endif]--><HTML>  

<!--[if !supportLists]-->2.  <!--[endif]-->        <HEAD>  

<!--[if !supportLists]-->3.  <!--[endif]-->                <script language="javascript" src="aaaaa.js"></script>  

<!--[if !supportLists]-->4.  <!--[endif]-->        </HEAD>  

<!--[if !supportLists]-->5.  <!--[endif]-->        <SCRIPT LANGUAGE="JavaScript">  

<!--[if !supportLists]-->6.  <!--[endif]--><!--  

<!--[if !supportLists]-->7.  <!--[endif]-->/**  

<!--[if !supportLists]-->8.  <!--[endif]--> * 表单验证的示例js方法.  

<!--[if !supportLists]-->9.  <!--[endif]--> */  

<!--[if !supportLists]-->10.<!--[endif]-->function check(){  

<!--[if !supportLists]-->11.<!--[endif]-->        if(checkIfEmpty('a','非空校验')  

<!--[if !supportLists]-->12.<!--[endif]-->                &&checkIsMail('b','邮箱校验')  

<!--[if !supportLists]-->13.<!--[endif]-->                &&checkIsNum('c','数字校验')  

<!--[if !supportLists]-->14.<!--[endif]-->                &&checkIsValid('d','合法性校验')  

<!--[if !supportLists]-->15.<!--[endif]-->                &&compareTwoDate('e','f','小日期与大日期关系错误!')  

<!--[if !supportLists]-->16.<!--[endif]-->                &&checkLength('g',5,'长度校验')  

<!--[if !supportLists]-->17.<!--[endif]-->                &&checkChooseSelect('h','下拉菜单非空','-1')  

<!--[if !supportLists]-->18.<!--[endif]-->                &&compareTwoNum('k','l','大小数目关系不正确!')){  

<!--[if !supportLists]-->19.<!--[endif]-->                alert('校验通过!');  

<!--[if !supportLists]-->20.<!--[endif]-->                return true;          

<!--[if !supportLists]-->21.<!--[endif]-->        }else{  

<!--[if !supportLists]-->22.<!--[endif]-->                return false;  

<!--[if !supportLists]-->23.<!--[endif]-->        }  

<!--[if !supportLists]-->24.<!--[endif]-->}  

<!--[if !supportLists]-->25.<!--[endif]-->  

<!--[if !supportLists]-->26.<!--[endif]-->/**  

<!--[if !supportLists]-->27.<!--[endif]--> * 取下拉菜单的值和文本的示例js方法.  

<!--[if !supportLists]-->28.<!--[endif]--> */  

<!--[if !supportLists]-->29.<!--[endif]-->function getSelect(){  

<!--[if !supportLists]-->30.<!--[endif]-->        var sss = $('h');  

<!--[if !supportLists]-->31.<!--[endif]-->        alert('下拉菜单选择的文本是:'+getSelectText(sss)+'\n'  

<!--[if !supportLists]-->32.<!--[endif]-->                        +'下拉菜单选择的值是:'+getSelectValue(sss));  

<!--[if !supportLists]-->33.<!--[endif]-->}  

<!--[if !supportLists]-->34.<!--[endif]-->  

<!--[if !supportLists]-->35.<!--[endif]-->/**  

<!--[if !supportLists]-->36.<!--[endif]--> * 根据键值字符串设置下拉菜单的显示内容.  

<!--[if !supportLists]-->37.<!--[endif]--> */  

<!--[if !supportLists]-->38.<!--[endif]-->function setSelect(){  

<!--[if !supportLists]-->39.<!--[endif]-->        var sss = $('i').value;  

<!--[if !supportLists]-->40.<!--[endif]-->        setSelectContent($('h'),sss);  

<!--[if !supportLists]-->41.<!--[endif]-->}  

<!--[if !supportLists]-->42.<!--[endif]-->  

<!--[if !supportLists]-->43.<!--[endif]-->/**  

<!--[if !supportLists]-->44.<!--[endif]--> * 返回多选框数组选择状态的id的字符串,结果以逗号隔开.  

<!--[if !supportLists]-->45.<!--[endif]--> */  

<!--[if !supportLists]-->46.<!--[endif]-->function getMulti(){   

<!--[if !supportLists]-->47.<!--[endif]-->        alert('多选选择的id是:'+getCheckedIds(document.getElementsByName('j')));  

<!--[if !supportLists]-->48.<!--[endif]-->}  

<!--[if !supportLists]-->49.<!--[endif]-->//-->  

<!--[if !supportLists]-->50.<!--[endif]--></SCRIPT>  

<!--[if !supportLists]-->51.<!--[endif]-->        <BODY>  

<!--[if !supportLists]-->52.<!--[endif]-->                <table>  

<!--[if !supportLists]-->53.<!--[endif]-->                        <tr>  

<!--[if !supportLists]-->54.<!--[endif]-->                                <td>  

<!--[if !supportLists]-->55.<!--[endif]-->                                        非空:  

<!--[if !supportLists]-->56.<!--[endif]-->                                        <input id='a'>  

<!--[if !supportLists]-->57.<!--[endif]-->                                </td>  

<!--[if !supportLists]-->58.<!--[endif]-->                                <td>  

<!--[if !supportLists]-->59.<!--[endif]-->                                        checkIfEmpty('a','非空校验')  

<!--[if !supportLists]-->60.<!--[endif]-->                                </td>  

<!--[if !supportLists]-->61.<!--[endif]-->                        </tr>  

<!--[if !supportLists]-->62.<!--[endif]-->                        <tr>  

<!--[if !supportLists]-->63.<!--[endif]-->                                <td>  

<!--[if !supportLists]-->64.<!--[endif]-->                                        邮箱:  

<!--[if !supportLists]-->65.<!--[endif]-->                                        <input id='b' value='323232@2323.com'>  

<!--[if !supportLists]-->66.<!--[endif]-->                                </td>  

<!--[if !supportLists]-->67.<!--[endif]-->                                <td>  

<!--[if !supportLists]-->68.<!--[endif]-->                                        checkIsMail('b','邮箱校验')  

<!--[if !supportLists]-->69.<!--[endif]-->                                </td>  

<!--[if !supportLists]-->70.<!--[endif]-->                        </tr>  

<!--[if !supportLists]-->71.<!--[endif]-->                        <tr>  

<!--[if !supportLists]-->72.<!--[endif]-->                                <td>  

<!--[if !supportLists]-->73.<!--[endif]-->                                        数字:  

<!--[if !supportLists]-->74.<!--[endif]-->                                        <input id='c' value='aaaa'>  

<!--[if !supportLists]-->75.<!--[endif]-->                                </td>  

<!--[if !supportLists]-->76.<!--[endif]-->                                <td>  

<!--[if !supportLists]-->77.<!--[endif]-->                                        checkIsNum('c','数字校验')  

<!--[if !supportLists]-->78.<!--[endif]-->                                </td>  

<!--[if !supportLists]-->79.<!--[endif]-->                        </tr>  

<!--[if !supportLists]-->80.<!--[endif]-->                        <tr>  

<!--[if !supportLists]-->81.<!--[endif]-->                                <td>  

<!--[if !supportLists]-->82.<!--[endif]-->                                        合法字符:  

<!--[if !supportLists]-->83.<!--[endif]-->                                        <input id='d' value='@$@$#$#!%%#'>  

<!--[if !supportLists]-->84.<!--[endif]-->                                </td>  

<!--[if !supportLists]-->85.<!--[endif]-->                                <td>  

<!--[if !supportLists]-->86.<!--[endif]-->                                        checkIsValid('d','合法性校验')  

<!--[if !supportLists]-->87.<!--[endif]-->                                </td>  

<!--[if !supportLists]-->88.<!--[endif]-->                        </tr>  

<!--[if !supportLists]-->89.<!--[endif]-->                        <tr>  

<!--[if !supportLists]-->90.<!--[endif]-->                                <td>  

<!--[if !supportLists]-->91.<!--[endif]-->                                        小的日期:  

<!--[if !supportLists]-->92.<!--[endif]-->                                        <input id='e' value='2010-1-1'>  

<!--[if !supportLists]-->93.<!--[endif]-->                                        大的日期:  

<!--[if !supportLists]-->94.<!--[endif]-->                                        <input id='f' value='2011-1-1'>  

<!--[if !supportLists]-->95.<!--[endif]-->                                </td>  

<!--[if !supportLists]-->96.<!--[endif]-->                                <td>  

<!--[if !supportLists]-->97.<!--[endif]-->                                        compareTwoDate('e','f','小日期与大日期关系错误!')  

<!--[if !supportLists]-->98.<!--[endif]-->                                </td>  

<!--[if !supportLists]-->99.<!--[endif]-->                        </tr>  

<!--[if !supportLists]-->100.  <!--[endif]-->                        <tr>  

<!--[if !supportLists]-->101.  <!--[endif]-->                                <td>  

<!--[if !supportLists]-->102.  <!--[endif]-->                                        小的数:  

<!--[if !supportLists]-->103.  <!--[endif]-->                                        <input id='k' value='12.3'>  

<!--[if !supportLists]-->104.  <!--[endif]-->                                        大的数:  

<!--[if !supportLists]-->105.  <!--[endif]-->                                        <input id='l' value='4564'>  

<!--[if !supportLists]-->106.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->107.  <!--[endif]-->                                <td>  

<!--[if !supportLists]-->108.  <!--[endif]-->                                        compareTwoNum('k','l','大小数目关系不正确!')  

<!--[if !supportLists]-->109.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->110.  <!--[endif]-->                        </tr>  

<!--[if !supportLists]-->111.  <!--[endif]-->                        <tr>  

<!--[if !supportLists]-->112.  <!--[endif]-->                                <td>  

<!--[if !supportLists]-->113.  <!--[endif]-->                                        字符长度校验(<5):  

<!--[if !supportLists]-->114.  <!--[endif]-->                                        <input id='g'>  

<!--[if !supportLists]-->115.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->116.  <!--[endif]-->                                <td>  

<!--[if !supportLists]-->117.  <!--[endif]-->                                        checkLength('g',5,'长度校验')  

<!--[if !supportLists]-->118.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->119.  <!--[endif]-->                        </tr>  

<!--[if !supportLists]-->120.  <!--[endif]-->                        <tr>  

<!--[if !supportLists]-->121.  <!--[endif]-->                                <td>  

<!--[if !supportLists]-->122.  <!--[endif]-->                                        下拉菜单非空校验:  

<!--[if !supportLists]-->123.  <!--[endif]-->                                        <select id='h'>  

<!--[if !supportLists]-->124.  <!--[endif]-->                                                <option value='-1'>  

<!--[if !supportLists]-->125.  <!--[endif]-->                                                        请选择  

<!--[if !supportLists]-->126.  <!--[endif]-->                                                </option>  

<!--[if !supportLists]-->127.  <!--[endif]-->                                                <option value='1'>  

<!--[if !supportLists]-->128.  <!--[endif]-->                                                        立项  

<!--[if !supportLists]-->129.  <!--[endif]-->                                                </option>  

<!--[if !supportLists]-->130.  <!--[endif]-->                                                <option value='2'>  

<!--[if !supportLists]-->131.  <!--[endif]-->                                                        可研  

<!--[if !supportLists]-->132.  <!--[endif]-->                                                </option>  

<!--[if !supportLists]-->133.  <!--[endif]-->                                        </select>  

<!--[if !supportLists]-->134.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->135.  <!--[endif]-->                                <td>  

<!--[if !supportLists]-->136.  <!--[endif]-->                                        checkChooseSelect('h','下拉菜单非空','-1')  

<!--[if !supportLists]-->137.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->138.  <!--[endif]-->                        </tr>  

<!--[if !supportLists]-->139.  <!--[endif]-->                        <tr>  

<!--[if !supportLists]-->140.  <!--[endif]-->                                <td colspan='2'>  

<!--[if !supportLists]-->141.  <!--[endif]-->                                        <button onclick='check()'>  

<!--[if !supportLists]-->142.  <!--[endif]-->                                                测试表单校验方法  

<!--[if !supportLists]-->143.  <!--[endif]-->                                        </button>  

<!--[if !supportLists]-->144.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->145.  <!--[endif]-->                        </tr>  

<!--[if !supportLists]-->146.  <!--[endif]-->                        <tr>  

<!--[if !supportLists]-->147.  <!--[endif]-->                                <td>  

<!--[if !supportLists]-->148.  <!--[endif]-->  

<!--[if !supportLists]-->149.  <!--[endif]-->                                        <button onclick='getSelect()'>  

<!--[if !supportLists]-->150.  <!--[endif]-->                                                得到下拉菜单的值  

<!--[if !supportLists]-->151.  <!--[endif]-->                                        </button>  

<!--[if !supportLists]-->152.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->153.  <!--[endif]-->                                <td>  

<!--[if !supportLists]-->154.  <!--[endif]-->                                        getSelectText(sss)和getSelectValue(sss)  

<!--[if !supportLists]-->155.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->156.  <!--[endif]-->                        </tr>  

<!--[if !supportLists]-->157.  <!--[endif]-->                        <tr>  

<!--[if !supportLists]-->158.  <!--[endif]-->                                <td>  

<!--[if !supportLists]-->159.  <!--[endif]-->                                        输入下拉菜单的键值字符串(如右所示)  

<!--[if !supportLists]-->160.  <!--[endif]-->                                        <input id='i' value='1,男;2,女;3,未知'>  

<!--[if !supportLists]-->161.  <!--[endif]-->                                        <button onclick='setSelect()'>  

<!--[if !supportLists]-->162.  <!--[endif]-->                                                设置下拉菜单的值  

<!--[if !supportLists]-->163.  <!--[endif]-->                                        </button>  

<!--[if !supportLists]-->164.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->165.  <!--[endif]-->                                <td>  

<!--[if !supportLists]-->166.  <!--[endif]-->                                        setSelectContent($('h'),sss)  

<!--[if !supportLists]-->167.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->168.  <!--[endif]-->                        </tr>  

<!--[if !supportLists]-->169.  <!--[endif]-->                        <tr>  

<!--[if !supportLists]-->170.  <!--[endif]-->                                <td>  

<!--[if !supportLists]-->171.  <!--[endif]-->  

<!--[if !supportLists]-->172.  <!--[endif]-->                                        <input type='checkbox' name='j' value='aaa1'>  

<!--[if !supportLists]-->173.  <!--[endif]-->                                        <input type='checkbox' name='j' value='aaa2'>  

<!--[if !supportLists]-->174.  <!--[endif]-->                                        <input type='checkbox' name='j' value='aaa3'>  

<!--[if !supportLists]-->175.  <!--[endif]-->                                        <input type='checkbox' name='j' value='aaa4'>  

<!--[if !supportLists]-->176.  <!--[endif]-->                                        <button onclick='getMulti()'>  

<!--[if !supportLists]-->177.  <!--[endif]-->                                                得到多选选择的id  

<!--[if !supportLists]-->178.  <!--[endif]-->                                        </button>  

<!--[if !supportLists]-->179.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->180.  <!--[endif]-->                                <td>  

<!--[if !supportLists]-->181.  <!--[endif]-->                                        getCheckedIds(document.getElementsByName('j'))  

<!--[if !supportLists]-->182.  <!--[endif]-->                                </td>  

<!--[if !supportLists]-->183.  <!--[endif]-->                        </tr>  

<!--[if !supportLists]-->184.  <!--[endif]-->                </table>  

<!--[if !supportLists]-->185.  <!--[endif]-->        </BODY>  

<!--[if !supportLists]-->186.  <!--[endif]--></HTML>  

原文地址:https://www.cnblogs.com/shallwe99/p/2467917.html