jQuery: set the width of a textarea?

Posted by AP257 on Stack Overflow See other posts from Stack Overflow or by AP257
Published on 2010-12-30T21:41:21Z Indexed on 2010/12/30 21:53 UTC
Read the original article Hit count: 105

Filed under:
|

What it says on the tin: how do I set the width of a textarea in jQuery?

I want to set the width of a textarea to match the width of a particular image. Using .width() works for setting the width of an image, but not of a textarea.

$(document).ready(function() {
    var width = $("#my_image").width();
    $("#another_image").width(width); // works
    $("#my_textarea").width(width); // fails
});

How do I set the width of a textarea?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html