单击按钮后,如何重置输入字段?
<div class="form-group autocomplete">
<div class="input-group search">
<input id="search" name="searchterm" type="search" class="form-control form-control search-input" placeholder="" autocomplete="off">
<div class="input-group-btn">
<button type="button" class="btn color-cta-3 search-button" onmousedown="getInput();alert('Danke fuer Ihre Eingabe Thank you'); return false;" >Eingabe</button></div></div>
<script>
function getInput(){
ET_Event.eventStart('TestCloud', document.getElementById('search').value, 'TestCloud')
}
</script>
&#13;
答案 0 :(得分:1)
尝试使用此代码,您的代码中会有一些不需要的代码。
<div class="form-group autocomplete">
<div class="input-group search">
<input id="search" name="searchterm" type="search" class="form-control form-control search-input" placeholder="" autocomplete="off">
<div class="input-group-btn">
<button type="button" class="btn color-cta-3 search-button" onclick="getInput();">Eingabe</button>
</div>
</div>
</div>
<script>
function getInput() {
document.getElementById('search').value = '';
alert('Danke fuer Ihre Eingabe Thank you');
}
</script>
答案 1 :(得分:1)
以下是使用jQuery删除内容的简化示例。
$("#delete-button").click(()=>{
$("#search").val("")
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="search" name="searchterm" type="search" class="form-control form-control search-input" placeholder="" autocomplete="off">
<button id="delete-button">Delete</button>
答案 2 :(得分:0)
设置输入值=&#39;&#39;;
document.getElementById(&#39; search&#39;)。value =&#39;&#39;;
<div class="form-group autocomplete">
<div class="input-group search">
<input id="search" name="searchterm" type="search" class="form-control form-control search-input" placeholder="" autocomplete="off">
<div class="input-group-btn">
<button type="button" class="btn color-cta-3 search-button" onmousedown="getInput();alert('Danke fuer Ihre Eingabe Thank you'); return false;" >Eingabe</button></div></div>
<script>
function getInput(){
//ET_Event.eventStart('TestCloud', document.getElementById('search').value, 'TestCloud')
document.getElementById('search').value = '';
}
</script>
&#13;