22智能在线
新记
html 加载图片的问题,js控制添加图片
网页打开后,点击button控制显示一张图片(图片不是预加载出来设置隐藏的)是在点击button后在服务器上拿的,菜鸟求教
举报该文章
相关建议 推荐于2016-02-15
哈哈,
<script>
window.onload=function(){
document.getElementById("btn").click=function(){
var imgUrl="
https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/iknow/avarta/66/r6s1g9.gif";
//生成图片标签对象
var oImg=document.createElement(img);
oImg.src=imgUrl;
document.body.appendChild(oImg);
}
}
</script>
<button id="btn">显示图片</button>
追问
不行呃……没有反应啊
温馨提示:内容为网友见解,仅供参考
当前网址:
https://22.t2y.org/zz/fh2fsh00xxhxhxcs0h6.html
其他看法
无其他回答
相似回答
大家正在搜
相关问题
javascript怎么动态添加图片
想在一个div里面添加图片,用js怎么写啊?
html和js显示图片问题
怎么用javascript向html中添加图片呢?
js中创建img元素追加src属性添加图片 运行HTML图片...
想在一个div里面添加图片,用js怎么写啊?
求JS控制网页图片加载代码
js如何插入图片?