处理以上数据
<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>
效果图:
<script type="text/javascript">
$(function ()
{
var json = [
{ "id": "1", "tagName": 1 },
{ "id": "2", "tagName": "orange" },
{ "id": "3", "tagName": "banana" },
{ "id": "4", "tagName": "watermelon" },
{ "id": "5", "tagName": "pineapple" }
]; var json1 = { "id": 1, "tagName": "apple" }; var aa= $.param(json);
$("#fm").click(function () { json.forEach(function myfunction(aa) {
alert(aa.id +" ="+aa.tagName);
}); });
}); </script>
效果图: