//正则分割字符串
1 var ids=document.getElementsByClassName("div2"); 2 var cls=ids[0].className.split(/\s+/); 3 alert(cls.length); 4 for (var i = 0; i <cls.length; i++) { 5 if(cls[i] == "divs"){ 6 alert(i+" "+cls[i]); 7 }else if(cls[i] == "div2"){ 8 alert(i+" "+cls[i]); 9 }else{ 10 alert(i+" "+cls[i]); 11 } 12 }
1 ~~~~~~~~~~~神奇的分割线~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 3 // 检测页面处于加载还是完成状态,有2个值 onload和conmplete 4 if(document.readyState=="onload"){ 5 alert("onload"); 6 }else{ 7 alert("ready"); 8 } 9 10 ~~~~~~~~~~~神奇的分割线~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 11 12 // 检测页面采用标准模式(CSS1Compat)渲染还是兼容模式(BackCompat)渲染 13 if(document.compatMode == "CSS1Compat"){ 14 alert("CSS1Compat"); 15 }else if(document.compatMode == "BackCompat"){ 16 alert("BackCompat"); 17 }else{ 18 alert(" "); 19 }
原文地址:https://www.cnblogs.com/mhxy13867806343/p/8447150.html
时间: 2024-11-11 04:48:34