【发布时间】:2015-12-14 03:04:33
【问题描述】:
我要带
一个var = input
并将 eg: 5 添加到该输入中,然后我想将我的输入打印到我的 html 文件中。
例如:(我知道匹配
getElementbyIds,我只是在显示我的答案和附加时遇到了麻烦。
<script>
funtion printmsg (){
var a = document.getElementById("myInput").value;
var b = a+5;
return b;
/*i would like to keep my p[rogram going and appending the answers until i tell the program to stop.*/
</script>
<body>
<input id="myinput">
<button onclick="printmsg">print</button>
<span id="display"></span>
</body>
【问题讨论】:
-
输出什么元素或者?只输出.. 如果只输出试试 alert(b);
-
拥有您正在使用的 HTML 可能会有所帮助,具体答案将部分取决于它。
-
我想在我的 html 中做,而不是在我尝试做 innerHTML=b 的窗口中;
-
您的代码中有错误,您将
function拼错为funtion -
请查看控制台是否有错误。
标签: javascript html input output