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?
Use jQuery's css
method like this:
.css("width", width)
or this, if you plan on setting more attributes:
.css({"width":width})
You could try :
$("#my_textarea").css('width', width);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With