更新时间:2023-01-14 11:44:32
它不起作用,因为 name
是 JavaScript 中的保留字.将函数名称更改为其他名称.
It doesn't work because name
is a reserved word in JavaScript. Change the function name to something else.
参见 http://www.quackit.com/javascript/javascript_reserved_words.cfm
<form id="form" onsubmit="return false;">
<input style="position:absolute; top:80%; left:5%; width:40%;" type="text" id="userInput" />
<input style="position:absolute; top:50%; left:5%; width:40%;" type="submit" onclick="othername();" />
</form>
function othername() {
var input = document.getElementById("userInput").value;
alert(input);
}