<!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); //When deleted, the array length is reduced
j--;
}
}
}
alert(arr.toString());
//$("#dl").val(arr.toString());// The generated strings are separated by commas
$("#dl").val(arr.join(""));//The generated string has no separator
$("#dl").val(arr.join("-"));//The join method specifies the separator of the generated string
$("#dl").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>