Posted in Javascript onOctober 04, 2012
<script type="text/javascript"> // Close HTML Tags -------------------------------------------- function closeHTML(str){ var arrTags=["span","font","b","u","i","h1","h2","h3","h4","h5","h6","p","li","ul","table","div"]; for(var i=0;i<arrTags.length;i++){ var intOpen=0; var intClose=0; var re=new RegExp("\\<"+arrTags[i]+"( [^\\<\\>]+|)\\>","ig"); var arrMatch=str.match(re); if(arrMatch!=null) intOpen=arrMatch.length; re=new RegExp("\\<\\/"+arrTags[i]+"\\>","ig"); arrMatch=str.match(re); if(arrMatch!=null) intClose=arrMatch.length; for(var j=0;j<intOpen-intClose;j++){ str+="</"+arrTags[i]+">"; } /*for(var j=(intOpen-intClose-1);j>=0;j--){ str+="</"+arrTags[i]+">"; }*/ } return str; } </script>
js自动闭合html标签(自动补全html标记)
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@