jquery的map函数,解析json数组

1、
<script>
   var arr = $([{
				"name": "jack",
				"age": "13"
			}, {
				"name": "jim",
				"age": "15"
			}]).map(function() {
				return {
					"name": this.name,
					"age":this.age
				};
			}).get();
			
			console.log(arr)
</script>
 


2、
        <div><input type="checkbox" />1</div>
		<div><input type="checkbox" />2</div>
		<div><input type="checkbox" checked="checked" />3</div>
		<div><input type="checkbox" />4</div>
		<div><input type="checkbox" checked="checked" />5</div>
		<div><input type="checkbox" />6</div>
            var a = $("div").has(":checked").map(function() {
				return {
					path: $(this).text(),
					name: $(this).text()
				};
			}).get();
            console.log(a);

posted @ 2020-11-15 09:54  jungu  阅读(219)  评论(0)    收藏  举报