element height after content change

Posted by Neph on Stack Overflow See other posts from Stack Overflow or by Neph
Published on 2012-11-23T17:01:26Z Indexed on 2012/11/23 17:04 UTC
Read the original article Hit count: 169

Filed under:
|
|

I have a snippet of code that alters the contents of a DIV to match the contents of a textarea and then applies the height change in the DIV to the textarea element.

    function growTextArea(parameter) {
     $('div').find("[data-fieldid='1_description']").text($(parameter).val());

// No Works
     height = $('.hiddenDiv').find("[data-fieldid='1_description']").outerHeight();
     alert(height);

// Works
     heightDiv = $('.hiddenDiv').outerHeight();
     alert(heightDiv);

     $(parameter).css('height', $('div').find("[data-fieldid='1_description']").outerHeight());
}

The DIV contents change properly, so the search function is working properly, however the search function always returns the original height of the DIV. The function is called by onKeyUp in the textarea. If the .find is swapped out for a .hiddenDiv the height change is reflected properly.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery