Posted in jQuery onApril 11, 2018
本文实例讲述了jQuery实现合并/追加数组并去除重复项的方法。分享给大家供大家参考,具体如下:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>3water.com jQuery不重复地追加数组元素</title> </head> <body> <script lanage="javaScript" src="jquery.js"></script> <script lanage="javaScript"> <!-- 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> </body> </html>
运行结果:
[原创]jQuery实现合并/追加数组并去除重复项的方法
- Author -
shichen2014声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@