jQuery blur() and click()

Your issue is that click fires on the button on mouseup, however when you change the height, that makes it to where your mouse is no longer on the button when the mouseup happens. Use mousedown instead of click and then trigger('blur') on the textarea to make both events happen.

Note: you still need a click event in there just so you can return false to cancel out the default form submission functions.

fiddle


$('.entryButton').on('click', function (e) {
    return false; // to prevent default form post
});
$("form").delegate('.entryButton','mousedown', function() {
    $('textarea').trigger('blur');
    var form = $(this).closest("form");
    var id = form.attr('id');
    var text = form.find("textarea").val();
    $("#test").append(text);                 

    //Prevent the form from being submitted (default HTML)
    return false;
});

and keep the focus and blur function as before.

thanks.

Tags:

Jquery