Home  >  Article  >  Web Front-end  >  html<img>标签中src=“图片路径”,怎样用变量替换路径_html/css_WEB-ITnose

html<img>标签中src=“图片路径”,怎样用变量替换路径_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:37:332981browse

我定义了一个变量,变量将图片路径传给src,可是照片怎么样都不显示,该怎么办,试了很多方法都不行

例如:
var  url;
html<img>标签中src=“图片路径”,怎样用变量替换路径_html/css_WEB-ITnose


回复讨论(解决方案)

方法一

<img  id="pic" / alt="html<img>标签中src=“图片路径”,怎样用变量替换路径_html/css_WEB-ITnose" ><script type="text/javascript">var  url = "xxx.jpg";document.getElementById("pic").src = url;</script>

方法二

<script type="text/javascript">var  url = "xxx.jpg";document.write('<img  src="'+url+'" / alt="html<img>标签中src=“图片路径”,怎样用变量替换路径_html/css_WEB-ITnose" >');</script>

var sContent =
"html<img>标签中src=“图片路径”,怎样用变量替换路径_html/css_WEB-ITnose" + 
"";
var infoWindow = new BMap.InfoWindow(sContent);

这是源码,我想将src的值用一个变量传进去,显示在定义的信息窗口,该怎么做啊

var  url = "images/1.jpg";var sContent ="<div><img    style="max-width:90%" src = '" + url + "'   style="max-width:90%"  style="max-width:90%"/ alt="html<img>标签中src=“图片路径”,怎样用变量替换路径_html/css_WEB-ITnose" >" + "</div>";var infoWindow = new BMap.InfoWindow(sContent);

哈哈,好了,谢谢了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn