html 加载图片的问题,js控制添加图片

网页打开后,点击button控制显示一张图片(图片不是预加载出来设置隐藏的)是在点击button后在服务器上拿的,菜鸟求教

哈哈,

<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>

追问

不行呃……没有反应啊

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答