Would solve the problem you mentioned using the onkeypress event in input or from jQuery with the keypress method if it is empty or not empty, example:
HTML:
<input type="text" id="inputText">
<div id="conteudo">
Javascript:
$('#inputText').keypress(function (){
if (this.value != ''){
$('#conteudo').innerHTML = '';
} else {
$('#conteudo').innerHTML = 'O campo não está preenchido';
}
});
If you prefer you can use the method . remove when it is not empty, but when it is empty again the div will not be found and consequently will not be filled when the user leaves the field empty, example:
$('#conteudo').remove();
I hope it helped you, any doubt we are here.
I don’t know if I got it right, but I think you’re looking for the job
keypress
. I created a little fiddle here, see if this is what you’re looking for: http://jsfiddle.net/gustavox/aVyuB/101/ ?– gustavox
Basically, need bind for another event -
click
is just one of several.– brazilianldsjaguar