$("#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.