Copy Code code as follows:
<! DOCTYPE html>
<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 length of the array 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 ("-)");//join method to specify the delimiter of the generated string
$ ("#dl"). attr ({"Style": "});
})
});
</script>
<body>
<input id= "org" type= "text" value= "Hhuummqqhhuummss"/>
<button type= "button" > Remove repeat </button>
<input id= "DL" type= "text" style= "Display:none"/>
</body>