【发布时间】:2018-04-14 14:17:14
【问题描述】:
如果你输入像 600 这样的随机数,他们希望程序打印“它由三位数字组成”,他们希望有一个循环并从用户那里获取输入。我们不能使用 document.write("" );抱歉,如果已经存在类似的帖子,我找不到我要找的东西。我的想法的一部分基本上是输入,按钮并使用 document.getelementbyid 获取输入,并以某种方式用内部 html 显示它。提前致谢!
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<p id="result">Hello, please enter a number and the program will show the number of digits
the number is made of.</p>
<input id="input1" name="x" placeholder="Enter a number " />
<button onclick="result()">submit</button>
<script>
function firstFunction() {
var input = document.getElementById("input1");
var result = result();
document.getElementById("result").innerHTML = ;
}
function result(){
//function for the cycle
}
</script>
</body>
</html>
【问题讨论】:
标签: javascript html loops cycle