Reputation: 93823
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?
Upvotes: 12
Views: 11211
Reputation: 62392
$("#my_textarea").css('width',width);
Also you might want to use .outerWidth() to set var width
depending on your padding/margin/border settings
Upvotes: 1