页面展示效果:

 JavaScript生成批量<div>标签

脚本展示:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
	div>div{
		width: 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" >
<input type="button" value="添加" onclick="myfn()">
<div ></div>
</body>
</html>

 

相关文章:

  • 2021-11-29
  • 2021-11-23
  • 2021-05-06
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-09
  • 2021-08-25
  • 2021-11-16
  • 2021-11-20
  • 2021-12-29
  • 2022-01-01
相关资源
相似解决方案