js去除范围内所有标签并显示指定字符串
代码:
<div id="txt"></div> <script type="text/javascript"> function removeLabel(){ var txt = document.getElementById("txt").innerHTML; if(txt==null||txt.length==0){ setInterval(removeLabel(),500); }else{ document.getElementById("txt").innerHTML=txt.replace(/<.*?>/ig,"").substr(0,100); } } window.addEventListener("load",removeLabel,true); </script>
IE下为attachEvent