<div class="codetitle"> <span><a style="CURSOR: pointer" data="46703" class="copybut" id="copybut46703" onclick="doCopy('code46703')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code46703"> <br><script type="text/javascript"> <br>// HTML 태그 닫기 ----------------------------- -- <br>function closeHTML(str){ <br>var arrTags=["span","font","b","u","i","h1","h2","h3", "h4","h5","h6","p","li","ul","테이블","div"]; <br>for(var i=0;i<arrTags.length;i ){ <BR>var intOpen=0; <BR>var intClose=0; <BR>var re=new RegExp("\<" arrTags[i] "( [^\<\>] |)\>","ig"); <br>var arrMatch=str.match(re); <br>if(arrMatch!=null) intOpen=arrMatch.length; <br>re=new RegExp("\<\/" arrTags[i] "\>","ig"); <br>arrMatch=str.match(재); <br>if(arrMatch!=null) intClose=arrMatch.length; <br>for(var j=0;j<intOpen-intClose;j ){ <BR>str ="</" arrTags[i] ">"; <br>} <br>/*for(var j=(intOpen-intClose-1);j>=0;j--){ <br>str ="</" arrTags[i] ">" ; <br>}*/ <br>} <br>return str; <br>} <br></script> <br> </div>