<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>js</title>
<style>
div{
background: greenyellow;
height: 200px;
border: 1px solid red;
}
</style>
</head>
<body>
<a href="http://www.baidu.com">小鸟博客<br></a>
<div id="myDiv"> 111 <span>节假日</span> </div>
<div > 222 </div>
<script>
//先找到div
var my = document.getElementById("myDiv");
/*
//在后台展示div里的内容
console.log(my.innerHTML);
*/
//修改div里面的内容
// my.innerHTML = "";
//需要一个变量,将所有的字符串放在里面,如变量 allline 为空;
var allline ="";
var jon =5;
for(var j=0;j<jon;j++){
//行
var len = j+1;
var oneline = "";
for(var i=0;i<len;i++){
oneline+="*";
}
// document.write(oneline+"<br>");
//换行
oneline +="<br>";
//获取的每一行加载到allline中;
allline += oneline;
}
//将allline赋值给innerHTML ;
my.innerHTML = allline;
</script>
</body>
</html>