keyevent - Javascript: escape key clears text in firefox -
i have input type text functionality. text has focus in meantime text can change. when press escape key should close. did bind key event , works fine. problem in firefox text clears when pressing escape key. can test here:
$('#asd').click(function() { $(this).val('huhu'); }); $('#asd').keydown(function(e) { if(e.which == 27) { e.preventdefault(); return false; } });
click in textfield , press escape. text disappears. tried prevent it's not working.
what can prevent that?
super dirty guess i'm using that:
$('#asd').click(function() { $(this).val('huhu'); }); $('#asd').keydown(function(e) { if(e.which == 27) { var $this = $(this); $this.blur(); settimeout(function() { $this.focus(); }, 10); } });
Comments
Post a Comment