remove icon for input with css and jquery

人走茶凉 提交于 2019-12-25 01:31:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!