【发布时间】:2014-11-26 10:56:23
【问题描述】:
我有一个代码,一个数学表编码器。同一页..
<!doctype html>
<html>
<head>
<title>Tafel Trainer</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<section id="content">
<p>Wilt u de tafels leren? Klik op de knop oefenen</p>
<button id="oefenen" name="oefenen" value="oefenen" onclick='oefenen()';>Tafel oefenen!</button>
<div id="1">
<script type='text/javascript'>
function oefenen(){
var num = prompt("Zet een cijfer neer", "0");
var num1 = parseInt(num);
for(i= 1; i< 11; i++) {
document.writeln("<table border='1'><tr><td>" + i + " x " + num1 + " = " + i * num1 + "<br/></td></tr></table>");
}
}
</script>
</div>
</section>
</body>
</html>
我已经尝试过使用 document.getElementByID('div1').innerHTML = i;但是那个代码也没有工作,我确定这是初学者的错,但是什么:)?
提前致谢!
【问题讨论】:
-
您可能希望使用比
document.write更传统的方法。试试appendChild或innerHTML -
让我试试,谢谢你的快速回复:)
-
没用,我就是想要在按钮下
标签: javascript html css loops for-loop