开发者

How to: On keypress get textarea1 height and set height to textarea2

I have 2 textareas (textarea1 and textarea2). On textarea1 im using an expander. As you type the textarea expands. Now, what ever you type on the textarea1 is written on textarea2 but the second textarea doesn't expand. I am looking something that would get the height from textarea1 as im typing and set it to textarea2. I would image it would be something like:

$("#textarea1").bind("keyup keypress paste mouseup", function() {
    $('#textarea1').val().height== ('#textarea2').height??

or

开发者_C百科
$("#textarea1").bind("keyup keypress paste mouseup", function() {
    $('#textarea2').attr('height', $('#textarea1').val().height);

None of those work.

Thanks alot


$("#textarea1").bind("keyup keypress paste mouseup", function() {
    $('#textarea2').css('height', $('#textarea1').height());


$("#textarea2").css("height", $("#textarea1").height() + "px");

That should work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜