$("#NewPost").live("focus", function(){ $(this).animate({height:112},300); }).bind("keydown", function(e) { e = e || window.event; if (e.keyCode === 13 && e.ctrlKey) {sendPostY();} }); $(function(){ $(document).click(function(event) { if ($(event.target).closest("#NewPost").length) return; $("#NewPost").animate({height:26},300); event.stopPropagation(); }); }); 

It is necessary to make it so that if there is text in the #NewPost container, then when you click on the document, the block does not change the CSS properties in height. If there is no text, then when you click on a document, the block collapses.

  • one
    @Bagner, standard comment: on the page there can not be more than one element with one ID. All scripts that suggest the opposite will not work. - etki

1 answer 1

Maybe so?

 $(document).click(function() { if ($("#NewPost").text().length) $("#NewPost").animate({height:26},300); });