简体   繁体   English

隐藏或删除图像src = undefined

[英]hide or delete image src=undefined

I'm working with markers on google map and this is what happens 我正在使用Google地图上的标记,这会发生

I call this variable to the images and upload to the database and use a query to put two images into a single file (GROUP_CONCAT) 我将此变量称为图像,然后上传到数据库,并使用查询将两个图像放入一个文件(GROUP_CONCAT)

var image = markers[i].getAttribute("image");
image = image.split(",");

And here I show these pictures. 我在这里显示这些图片。

var html = div id = "iw-container" +

'a Href="'+image[0]+'" data-lightbox="roadtrip" <img src = "' + image [0] +" "width = 100" height = "100" / a  '+

'a Href="'+image[1]+'" data-lightbox="roadtrip" <img src = "' + image [1] + '" width = 100 "height =" 100 " / a  '+

'a Href="'+image[2]+'" data-lightbox="roadtrip" <img src = "' + image [2] + '" width = 100 "height =" 100 " / a  '+

'/ Div';

The problem is if a marker is less than 3 images, for example a marker has 2 images, one of the images appear broken. 问题是,如果标记少于3个图像,例如标记具有2个图像,则其中一个图像显示为损坏。 obviously because not defined. 显然是因为没有定义。 () ()

I wonder if there is any function or something to check if an image has the "SRC" undefined, remove it or hide it or do something to not appear. 我想知道是否有任何功能或某些检查图像是否具有未定义的“ SRC”,将其删除或隐藏或执行某些操作以使其不显示。

Any help is good, thanks :) 任何帮助都很好,谢谢:)

Code like this should get you past this issue: 像这样的代码应该使您摆脱这个问题:

var html = '';
for(var i=0;i < image.length; i++) {
  html += image[i];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM