处理以上数据
<script type="text/javascript"> $(function () { $("#fm").click(function () { var json = [ { "id": "1", "tagName": "apple" }, { "id": "2", "tagName": "orange" }, { "id": "3", "tagName": "banana" }, { "id": "4", "tagName": "watermelon" }, { "id": "5", "tagName": "pineapple" } ]; $.each(json, function myfunction(a,b) { alert(b.id); }); }); }); </script>
效果图:
1 <script type="text/javascript"> 2 $(function () 3 { 4 var json = [ 5 { "id": "1", "tagName": 1 }, 6 { "id": "2", "tagName": "orange" }, 7 { "id": "3", "tagName": "banana" }, 8 { "id": "4", "tagName": "watermelon" }, 9 { "id": "5", "tagName": "pineapple" } 10 ]; 11 12 var json1 = { "id": 1, "tagName": "apple" }; 13 14 var aa= $.param(json); 15 $("#fm").click(function () { 16 17 json.forEach(function myfunction(aa) { 18 alert(aa.id +" ="+aa.tagName); 19 }); 20 21 22 23 }); 24 }); 25 26 </script>
效果图:
时间: 2024-11-07 21:30:38