发布网友 发布时间:2022-05-16 17:36
共2个回答
热心网友 时间:2022-05-17 16:52
<script type="text/javascript"> // 先做一个数组 </SPAN></li>var str = "1@1@2@3@3@4@4@5@"; </SPAN></li>var ary = str.split("@"); </SPAN></li> // 去重的算法 </SPAN></li>var json = {}; </SPAN></li>for (var i = 0; i < ary.length; i++) { </SPAN></li> json["a"+ary[i]] = ary[i]; </SPAN></li>} // 查看结果 </SPAN></li>var str2 = ""; </SPAN></li>for (var key in json) { </SPAN></li> str2 += json[key]; } alert(str2); </script>热心网友 时间:2022-05-17 18:10
转换成数组,去掉重复,再组合好。<script language="javascript">