怎样才能在页面上打印str出来
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>练习</title>
<style type="text/css">
div {border:1px solid #ccc; border-left:none; border-bottom: none; border-top: none; display: inline-block;}
span {display: inline-block; border:1px solid #ccc; border-right:none; border-top: none; width: 80px;}
span:last-child {border-top: 1px solid #ccc;}
</style>
<script type="text/javascript">
var str = "<table id='table'>";
for(var i = 1; i<10; i++){
str +="<tr>";
for(var j = 1; j<=i; j++){
str += '<td>' + j + '*' + i + '=' + j*i + "</td>";
}
str += "</tr>"
}
str += '</table>';
console.log(str)
document.body.innerHTML = str;
document.getElementById("table").innerHTML = str;
</script>
</head>
<body>
</body>
</html>
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 2198 份
- 解答问题 5012 个
如果你有web端基础,既想进阶,又想进军移动端开发,那就来吧,我们专题为你带来的课程有HTML5、CSS3、移动基础、响应式、bootstrap、less等,让你在前端道路上畅通无阻!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星