<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
#show{
width:150px;
height: 280px;
margin:0 auto;
background:#2c2c2c;
color:red;
text-align:center;
}
</style>
<title>循环</title>
<script type="text/javascript" >
var str="";
for (i=1;i<10;i++ )
{
for(j=0;j<i;j++)
{
if(j==0||j==i-1||i==9)
{str+="*";}
else{str+=" "}
}
str+="</br>"
}
document.write("<div id='show'>"+str+"</div>");
</script>
</head>
<body>
</body>
</html>