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

WBOY
Release: 2016-06-24 11:37:33
Original
2930 people have browsed it

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

方法二

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

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);
Copy after login

哈哈,好了,谢谢了

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!