有两个文本区域具有完全相同的文本格式。 ID 是 textareaA
和 textareaB
。
我已经为 textareaA keyup 设置了一些东西。我的问题是如何在用户输入 textareaA
时设置 textareaB
以调整其宽度?
这是我尝试过的方法,但没有成功。
$(document).on("click blur keyup", ".fT", function() { // keyup responds with textareaA
var newWidth = $("#textareaA").val(); //does not work
$("#textareaB").width(newWidth);
});
最佳答案
使用 .css("proprety", "value")
JQuery 方法来执行此操作。
用法:
$(document).keyup(function(event)) {
$("#textareaB").css("width", "1000px");
});
用法(带变量):
var myVariable = 1000; /* integer here */
$(document).keyup(function(event)) {
$("#textareaB").css("width", myVariable.toString() + "px");
});
关于javascript - 使用 keyup 键入时调整文本区域宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28674110/