和“ ”(空格)是不同的

十一月 9th, 2007 by xLight

下面这段代码在fireFox和IE中的结果是不同的


function trim (str)
{
return str.replace(/ */g, '');
}

function getTextContent (el)
{
if (el.textContent) return el.textContent;
if (el.innerText) return el.innerText;
if (el.innerHTML) return
el.innerHTML.replace(/( )|( )|( )/g, ' ');
}

   here    is the text 0.123 

tag:javascript 正则


0 Responses to “ 和“ ”(空格)是不同的”

  1. No Comments

Leave a Reply

提示:如果你刚刚提交过评论,但是还没有被显示出来,请点击这里刷新一下: 刷新评论