문제

If I use this: <input class="search" type="text" id="input" onfocus="this.value=''" /> and I write for example: arduino and it searches for everything with the text arduino and after that I click on somewhere else on the webpage and then click on the input field again, the text clears out as it should, but I have to backspace once on my keyboard, to clear the results for arduino and show everything.

Why and how can I fix this? Thanks

jsfiddle code here

도움이 되었습니까?

해결책

Trigger the keyup handler onfocus:

http://jsfiddle.net/dErda/1/

$('#input').on('focus',function(){
        this.value='';
        $(this).keyup();
    });

다른 팁

Try this to clear search and show everything back:

$("input[type=text]").focus(function(){
  $(this).val('');    
    $('.input').hide();
     $("ul.filter li").show();
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top