页面展示效果:
脚本展示:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <style type="text/css"> div>div{ 50px; height: 100px; background-color: blue; margin: 15px; } </style> <script type="text/javascript"> function myfn(){ var d = document.getElementById("d1"); var input = document.getElementById("i1"); for(var i=0;i<input.value;i++){ d.innerHTML+="<div>aaa</div>"; } } </script> </head> <body> <input type="text" id="i1"> <input type="button" value="添加" onclick="myfn()"> <div id="d1"></div> </body> </html>