<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<script>
var htmlStr = '<table class="table table-bordered"> ';//使用bootstrap
for (var i = 1; i <= 9; i++){
htmlStr += '<tr>';
for (j = 1; j <= i; j++){
htmlStr += '<td>' + j + '*' +i + '=' + (i * j) + '</td>';
}
htmlStr += '</tr>';
}
htmlStr += '</table>';
document.write(htmlStr);
</script>
</body>
</html>
网页中效果:
![](https://images2015.cnblogs.com/blog/1142487/201704/1142487-20170412214430251-1577847498.png)