MAO-EYE 2017-02-12 10:21 采纳率: 100%
浏览 118

如何替换数据?

Good day.I deduce 50 blocks. Receive information from a file in JSON format. I get a link to a photo from JSON. I give it to the page. I need to change all the photos large on the small size photos in just one click. Please tell me how to change the link everywhere at once?

var image = data["info"][i]["img"]["big"];
block += '<img src="' + image + '"/>'; 
//image - link to photo

</div>
  • 写回答

1条回答 默认 最新

  • weixin_33690963 2017-02-12 10:43
    关注

    If all the images are displayed inside a single element like this

    <div id="gallery">
        <img ... >
        <img ....>
        .....
    </div>
    

    Then you could regenerate the entire contents of the div:

    var str = "";
    for (var i = 0; i < data["info"].length; i++) {
        str += '<img src="' + data["info"][i]["img"]["small"] + '"/>';
    }
    document.findElementById("gallery").innerHTML = str;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程