zoukankan      html  css  js  c++  java
  • js 点击往div里添加图片(实例)

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
    </head>
    <body>
    <script type="text/javascript">
        function a(){
            var img = document.createElement('img');//创建一个标签
            img.setAttribute('src','https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2146046871,2611785107&fm=27&gp=0.jpg');//给标签定义src链接
            document.getElementById('id').appendChild(img);//放到指定的id里
        }
    </script>
        <div onclick="a()">点击添加图片</div>
        <div id="id"></div>
    </body>
    </html>
  • 相关阅读:
    Gym
    博客搬家
    UVA
    UVA
    UVA
    UVA
    UVA
    UVA1589——xiangqi
    SDUSToj第十一次作业源代码格式问题
    【成长之路】【python】python基础3
  • 原文地址:https://www.cnblogs.com/junyi-bk/p/10675147.html
Copyright © 2011-2022 走看看