gpt4 book ai didi

javascript - 刷新页面后如何清除该值

转载 作者:行者123 更新时间:2023-11-29 19:07:29 25 4
gpt4 key购买 nike

需要帮助如何在刷新页面后清除文本框值?实际上,我在提交表单后使用搜索文本框仍然显示文本框中的值,它工作正常,但我希望在刷新页面时清除该值。
这是我的代码,

<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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com