所以我想做的事肯定已经做了几千次了。我只是找不到解决办法。
{
"ImageCollection": {
"Images": [{
"ImageID": "68",
"CatID": "1",
"Location": "/Images/Art/Full/68.gif",
"ClipLocation": "/Images/Art/Clips/68.gif",
"FullHeight": "504",
"FullWidth": "451"
},
{
"ImageID": "69",
"CatID": "1",
"Location": "/Images/Art/Full/69.gif",
"ClipLocation": "/Images/Art/Clips/69.gif",
"FullHeight": "364",
"FullWidth": "500"
},
etc.etc
]
}
}
我想在一个4列宽的表中显示图像。
<script type="text/javascript">
$.getJSON("/Service/GetJson.ashx?data=images", function(data) {
var jsObjectData = data.ImageCollection.Images;
var imageTable = "<table><tbody>";
var rowMarker = 1;
var targetRowEnd;
$.each(jsObjectData, function(i, item) {
if (
imageTable = imageTable + "<td class='artImageBox'>"; imageTable = imageTable + "<a title='Click To Add' class='artImage'>"; imageTable = imageTable + "<img id='ArtImg"; imageTable = imageTable + item.ImageID; imageTable = imageTable + "' src='../"; imageTable = imageTable + item.ClipLocation; imageTable = imageTable + "' alt='Click To Add' />"; imageTable = imageTable + "</a></td>";
}); imageTable = imageTable + "</tbody></table>"; alert(imageTable); $("body").append(imageTable);
});
</script>
但我还没算好放在哪儿
<tr> and the </tr>
.