Reputation: 11240
I have a text input with a label I've positioned over the top to work as a placeholder. I am familiar with the placeholder attribute, but it is not relevant to this task.
When the user types into the input, the placeholder label hides. But the problem, is that it actually takes a microsecond to happen - its not instant. Meaning you get a delay where the placeholder is covering your first few characters of text.
My html code is:
<div class="input-wrap">';
<div class="label" contenteditable="false">Write something</div>
<div id="input" contenteditable="true"></div>
</div>
jQuery:
$('.input-wrap').on('keyup','#status-input',function(){
$('#label').hide();
});
I've made a codepen example here.
How to make the label disappear as soon as something is typed without delay?
Upvotes: 2
Views: 103
Reputation: 190
Have you tried using the keydown
event instead?
http://codepen.io/anon/pen/Apxmy
Upvotes: 4