This article mainly describes how to delete the characters in the string, the need for friends can refer to the following
Code as follows: <! DOCTYPE html> <html> <head> <script src= "//ajax.googleapis.com/ajax/libs/jquery /1.8.3/jquery.min.js "> </script> <script> $ (document). Ready (function () { $ (" Button "). Click (function () { var str=$ (" #org "). Val (); var arr=str.split (" "); for (Var i=0; arr.length-1>i;i++) { for (var j=i+1;j<arr.length;j++) { if (arr[j]==arr[i)) { alert (arr.length ); Arr.splice (j,1); After deletion, the array length decreases j--; } } } alert (arr.tostring ()); //$ ("#dl"). Val (arr.tostring ()) ;//generated strings separated by commas $ ("#dl"). Val (Arr.join (""));//generated string no split character $ ("#dl"). Val (Arr.join ("-")); The Join method can specify the delimiter $ ("#dl") of the generated string. attr ({"Style": "}); }) }); </script> </head> <body> <input id= "org" type= "text" value= "Hhuummqqhhuummss"/> <button type= "button" > Remove duplicate </button> <input id= "DL" tYpe= "text" style= "Display:none"/> </body> </html>