weixin_33734785 2019-02-16 01:59 采纳率: 0%
浏览 36

如何显示所有图像

I get bunch of images from database which is a JSON file. i couldn't display all images on HTML page. I can only display one image on that page. I attached my code below. Anyone give me a hand

      success:function(data){
                    $.each(data, function(index, element) {

                    $('.serachImg').attr("src","/image/"+element.filename);
             });
           },

This is my HtML Code

     <div class="row" id="search-img-list" style="display:none">
                <!-- Single Product -->
                     <div class="col-12 col-sm-6 col-lg-4" id="single_product">
                             <div class="single-product-wrapper">
                                 <!-- Product Image -->
                             <div class="product-img">
                               <a class="route" href="">

              <img class="serachImg" src="" alt="">  <- I want to display here

                                </a>
                             </div>
                         </div>
                      </div>
                  </div>

Any idea would be helped me out from this problem

  • 写回答

2条回答 默认 最新

  • weixin_33717298 2019-02-16 03:05
    关注

    $('.serachImg').attr("src","/image/"+element.filename); -- this will update the attr of the single image that's already in the dom.

    Instead, you'll want to append new images to a container element (like a div) in the dom. So, you'd like want to do something like $('.product-img').append($('<html elements...><img src=yourImgSrc /></html content>'))

    评论

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程