JavaScript_Util_01

//记住细节往往能让自己更有效率。定义变量,打冒号



//XML文档空格bug补救方案

function cleanWhiteSpace(element){

  element=element||document;

 var cur = element.firstChild;

  while(cur != null){
//如果是文本节点,并且只包含空格
    if(cur.nodeType == 3 && !/S/.test(cur.nodeValue)){

     element.removeChild( cur );

   

   }else if( cur.nodeType == 1){

      cleanWhiteSpace( cur );

   }  

   cur = cur.nextSibling;

 }

}
原文地址:https://www.cnblogs.com/Lennyyi/p/Util.html