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>