所以我需要在我的div中显示列表项,根据用户的输入并验证它是一个正值......这就是我所拥有的:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Javascript</title>
</head>
<body>
<h1>Javascript</h1>
<div id="main">
<script>
var x =prompt("How many list items would you like?:")
if(x<0 || isNaN(x)){
document.getElementById("main").innerHTML="Invalid input";
}
do {
document.getElementById("main").innerHTML="This number is:" + x + '<br>';
x++; }
while (x<=10)
</script>
</div>
</body>
</html>