需要帮助如何在刷新页面后清除文本框值?实际上,我在提交表单后使用搜索文本框仍然显示文本框中的值,它工作正常,但我希望在刷新页面时清除该值。
这是我的代码,
<div class="form-group" style='float:left;margin-right:10px;' id="normal_search">
{!! Form::text('search', '', array('id'=>'yearly_search_id','class' => 'form-control','placeholder'=>trans('main.search').' '.trans('main.customer.title') )) !!}
</div>
使用本地存储,
localStorage.yearlySearchFilter = $("#yearly_search_id").val();
$("#yearly_search_id").val(localStorage.yearlySearchFilter);
最佳答案
在 Javascript 中你可以这样做:
function init() {
document.getElementById("normal_search").value = "";
}
window.onload = init;
或者在 jQuery 中简单地执行:
$(document).ready(function() {
$("#normal_search").val('');
});
关于javascript - 刷新页面后如何清除该值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41734406/