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

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

WBOY
WBOYoriginal
2016-06-24 11:37:332940parcourir

我定义了一个变量,变量将图片路径传给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);

哈哈,好了,谢谢了

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn