I have a textarea
field and a "submit" button just below, and added a onfocus
and onblur
event in that field. The onfocus
increases the height of the field, and onblur
returns to normal. I also added a onclick
event on the "submit" button to validate the textarea
field. However, the onblur
event is "nulling" on the first click the onclick
event of the "submit" button. The code is this:
HTML:
<textarea id="meutexto"></textarea>
<br>
<div id="botao">
<input type="button" value="enviar" />
</div>
Script:
$("#meutexto")
.on('focus',function(){
$(this).css('height','60px');
})
.on('blur',function(){
$(this).css('height','30px');
});
$("#botao input").on('click',function(){
$("#botao").html('Enviando texto...');
});
It happens that by clicking the "submit" button 1 time nothing happens. Only in the second click that the% of% "button" is changed to DIV
.
If I pay for the lines:
.on('blur',function(){
$(this).css('height','30px');
});
The script works. But I would not like to remove "Enviando texto..."
. What is wrong?