目前我有一个 Json 对象。
{"prev":["","demo\/medium\/Web081112_P001_medium.jpg"],"curr":["demo\/medium\/Web081112_P002_medium.jpg","demo\/medium\/Web081112_P003_medium.jpg"],"next":["demo\/medium\/Web081112_P004_medium.jpg","demo\/medium\/Web081112_P005_medium.jpg"]}
可以看到Json对象结构如下:
prev img1, img2
curr img1, img2
next img1, img2
img 是图像路径或 "" 。
我想要实现的是,有六个图片链接
<img src ="....."> and I would like define each of it to <img id= "prevIMG2" src ="">
And assign the prev img2 to that <img id= "prevIMG2" src ="demo/medium/Web081112_P001_medium.jpg">
对于那些没有价值的人,它不分配任何<img src="">
如何使用 jquery 实现这一点?谢谢
我用来改变图像路径的东西
$(document).ready(function(){
$.ajax({
type: "GET",
url: "scandir.php",
data: "page=5",
dataType: 'json',
success: function (data) {
$.each(data, function(index, element) {
if($.trim(this[0]) !== '')
$('#prevL').attr('src',data);
});
}
});
});