I wrote the following jQuery script, and I'm trying to make a "cool transition", lol. When you start typing # input-type input = text-box, the page should switch to the 'compose.php' (form) page when you type, and if you enter more than 19 characters, the text field should expand to 80% of the width when key press, if it is less than 30 characters, the field is returned up to 300 pixels.
Although the problem is that if you blur the input text field # of the post-area and then focus again, the download function reloads and the other (possibly entered) data in the compose.php file disappears.
The question arises: how to do this to prevent the last function from repeating after its occurrence? I looked at .unbind (), but, seeing that there is another function located simultaneously on the same ID, this also disables the extension function.
Thanks a lot! Very grateful for any answers :) (script below)
$('#post-area-input').keyup(function(){ if($('#post-area-input').val().length > 19){ $('#post-area-input').animate({width: '80%',}, 80, function(){}); } else { $('#post-area-input').animate({width: '300',}, 80, function(){}); } }); $('#post-area-input').blur(function(){ if($('#post-area-input').val().length < 19){ $('#post-area-input').animate({width: '300',}, 80, function(){}); } }); $('#post-area-input').keyup(function(){ $('#pcontent').load('compose.php').hide().fadeIn('slow'); });
source share