for循环语句
格式:for(初始值;循环条件;增量){
循环体
}
例子:for(i=1;i<=10;i++){
document.write();
}
<!Doctype html>
<html>
<head>
<meta charset="utf-8" >
<meta name="Author" content="qian" >
</head>
<body>
<input type="text" id="num1" />
<input type="button" value="提交" οnclick="num()" />
<script>
var num1 = document.getElementById("num1");
function num(){
var new_num1 = num1.value;
for(var i=1;i<=new_num1;i++){
var str="";
for(var j=1;j<=i;j++){
str+=new_num1;
}
a=Number(str);
document.write(a+"+");
sum+=a;
}document.write(sum);
}
</script>
</body>
</html>