这次给大家带来如何使用jQuery实现合并/追加数组并去除重,使用jQuery实现合并/追加数组并去除重的注意事项有哪些,下面就是实战案例,一起来看一下。
<meta><title>jQuery不重复地追加数组元素</title><script></script><script> <!-- var arr=["tmp1","tmp2","tmp3","tmp4"]; var arr2=["tmp1","tmp1","tmp5"]; for(i=0,len=arr2.length;i<len;i++){ if($.inArray(arr2[i],arr)<0){ arr.push(arr2[i]); } } console.log(arr); --> </script>
运行结果:
相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!
推荐阅读:
以上就是如何使用jQuery实现合并/追加数组并去除重的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号