简体   繁体   English

重置后退按钮上的表格(野生动物园)

[英]Reset form on back button (safari)

I'm trying to reset the form when the user click on the back button. 我正在尝试在用户单击后退按钮时重置表单。 Here is the code that I use. 这是我使用的代码。

<input type="text" name="name">
<input type="text" name="email>
...
$(function() {
   $('input[type=text]').attr('val', '');
});

This code is not working on Safari 6.0.2. 此代码不适用于Safari 6.0.2。 I notice that the page load event is not even fired when the user click on the back button. 我注意到,当用户单击后退按钮时,甚至不会触发页面加载事件。

What could be the problem ? 可能是什么问题呢 ?

There's no val attribute. 没有val属性。 Use the val method instead: 请改用val方法:

$(function() {
   $('input[type=text]').val('');
});

And, you missed a quote at the email field: 而且,您错过了email字段中的引用:

<input type="text" name="email>
                              ^ Insert a quote here

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM