最佳答案
这是 jQuery 代码:
$('input').each(function(){
var value = $(this).val();
var size = value.length;
// playing with the size attribute
//$(this).attr('size',size);
// playing css width
size = size*2; // average width of a char
$(this).css('width',size*3);
});
关于jQuery - 根据值的宽度调整表单输入的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9328682/