Copy codeThe Code is as follows: <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>