我类的一个学生引起了我的注意,我对此没有任何解释——而且我在搜索后也找不到。
点击提交按钮后,重置按钮不起作用。如果资源是通过 post 请求请求的,就好像浏览器会阻止重置。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<fieldset>
<legend>User Form</legend>
<label for="Username"></label>
<asp:TextBox ID="Username" runat="server"></asp:TextBox>
</fieldset>
<asp:Button runat="server" Text="Submit" />
<input type="button" onclick="window.document.forms[0].reset()" value="reset" />
</div>
</form>
</body>
</html>
最佳答案
当您单击重置时,条目将重置为默认值。默认值是由服务器呈现的值,在第一种情况下它是空字符串,但在发布发布值之后。 (http 是无状态协议(protocol))如果您尝试编辑发布的值,然后单击重置,您将看到原来发布的值将被恢复。
关于javascript - 为什么在此页面上回发后 form.reset() 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11267752/