<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>for两层嵌套</title>
<style type="text/css">
#ul1 li {width: 50px;height: 50px;background: #f00;list-style: none;position: absolute;}
</style>
</head>
<body>
<ul id="ul1"></ul>
<script type="text/javascript">
//排成一排
var oUl=document.getElementById('ul1');
for (var i = 0; i < 20; i++) {
oUl.innerHTML+='<li style="left:'+i*54+'px"> </li>';
};
</script>
</body>
</html>
for两层的嵌套的应用(小正方形的生成,排成一排)
最新推荐文章于 2023-04-28 12:35:54 发布