ana*_*nam 0 html css jquery json
我正在阅读json的图片.我有16个图像..我想通过升序来读取图像.id1,id2,id3等.
目前它们按降序加载
$(document).ready(function() {
var globe;
/* Reading the data from XML file*/
$.ajax({
type: "GET",
url: "photos.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('item').each(function() {
var path = $(this).attr('path');
var width = $(this).attr('width');
var height = $(this).attr('height');
var id = $(this).attr('id');
var alt = $(this).attr('alt');
var longdesc = $(this).find('longdesc').text();
var description = $(this).find('desc').text();
$('#myImageFlow').prepend('<img src="' + path + '" id=' + id + ' height="' + height + '" width="' + width + '" longdesc="' + longdesc + '" alt="' + alt + '"/>');
imgArr[i] = description;
});
}
});
});
Run Code Online (Sandbox Code Playgroud)
用.append()而不是.prepend()
试试这个
$('#myImageFlow').append('<img src="'+path+'" id='+id+' height="'+height+'" width="'+ width+'" longdesc="'+longdesc+'" alt="'+alt+'"/>');
imgArr[i] = description;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
169 次 |
| 最近记录: |