jq 替换数组中某个元素

替换数组中某个元素

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>

<script type="text/javascript" src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script>

</head>

<body>
<script>
var a1="two";
var arr = [ "one", "two", "three", "four"];
var result="";
$.each(arr, function(){
	var a=this;
	if(a1==a){
		return true;

	}
	   result+=a+',';	

});

   result=result.substring(0,result.length-1);//去掉最后一个“,”
  alert(result);        
        </script>
</body>
</html>

字符串转数组

如何把字符串"123,abc,xy,hi"转换成数组或者jQuery数组

var arr = '123,abc,xy,hi'.split(',');
  for(var i in arr){
  alert(arr[i])
  }

    原文作者:我是高手高手高高手
    原文地址: https://blog.csdn.net/haibo0668/article/details/78094484
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞