Note: innerHtml
requires innerHTML
. Html should be all capitalized
.
the following is the original question
the following code, document.getElementsByTagName
in countDown ()
is useless, but I can see it again when I print with console, why
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>8-17</title>
<script type="text/javascript">
var timeSecond = 5;
function countDown() {
document.getElementsByTagName("p")[0].innerHtml = timeSecond + "<a href=\"javascript:;\" onclick=\"history.back()\">";
//console.log(document.getElementsByTagName("p")[0].innerHtml = timeSecond + "<a href=\"javascript:;\" onclick=\"history.back()\">");
if (timeSecond > 1) {
timeSecond--;
setTimeout(countDown,1000);
}
}
countDown();
}
</script>
</head>
<body>
<h2></h2>
</body>
</html>