Has anyone encountered this issue before? I have a math table coding function, which runs when a button is clicked. However, when I click the button, the table appears on a new page instead of on the same page.
<!doctype html>
<html>
<head>
<title>Times Tables Trainer</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<section id="content">
<p>Do you want to practice your times tables? Click the practice button below.</p>
<button id="practice" name="practice" value="practice" onclick='practice()';>Practice Times Tables!</button>
<div id="1">
<script type='text/javascript'>
function practice(){
var num = prompt("Enter a number", "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>
I've already attempted to use document.getElementByID('div1').innerHTML = i; However, this code did not work. I believe it may be a beginner's mistake, but I'm not entirely sure. Any insights would be greatly appreciated!
Thank you in advance!