问题
I am trying to get this to work but it doesn't.
I have removed my code for cleanup and here is the jsfiddle code
I am trying to create the remove button that removes the input and also resets the search list
-----------------------
| | x | <- remove icon inside the input box
-----------------------
or
----------------------- ----------
| | | All | <- all button outside the input box
----------------------- ----------
I can't manage to get the code to work e.g. reset the search results
回答1:
Not sure it is what you are looking for...
Use HTML5 input type search:
<input class="search clearable" type="search" id="input"/>
Then add handler click for input:
$('#input').on('click',function(){
if(this.value === "" ) //case when user reset the input by clicking button
$(this).keyup();
});
DEMO
来源:https://stackoverflow.com/questions/17389405/remove-icon-for-input-with-css-and-jquery