在开始在搜索框中键入内容时如何清除附加的输入文本。 https://jsfiddle.net/adampavlov/u4hz3k6d/1/
<select class="form-control" name="reasons" id="sel1" required>
<option>Select reason</option>
<?php
$reason = array("Expected delivery date has changed and the product is arriving at a later date","Product is being delivered to a wrong address(Customer’s mistake)","Product is not required anymore.","Cheaper alternative available for lesser price.","I am not going to be available in town due to some urgent travel.","Change in delivery address, non deliverable pincode.");
foreach($reason as $item){
echo '<option value="'.strtolower($item).'">'.$item.'</option>';
}
?> </select>
<button type="submit" class="btn btn-primary" name="cancel">Submit</button>
答案 0 :(得分:2)
只需传递空值以输入焦点
$('a.dropdown-item').click(function(){
var search_txt = $(this).text();
$('.searchbox-input').val(search_txt);
});
$('.searchbox-input').focus(function(){
$(this).val('');
});
答案 1 :(得分:1)
您需要将焦点输入的值设置为空
$('.searchbox-input').focus(function(){
$(this).val(''); //setting the input field as empty using that single or double quotes
});