我想根据模型
中的值get将动态宽度设置为Html.TextBoxFor
@Html.TextBoxFor(m => m.Agenda, new { @readonly = "readonly", id = "abc",@style="width:auto" })
但这不起作用。我想根据模型中的“议程”值每次更改宽度。
答案 0 :(得分:0)
如果您尝试将文本框的宽度设置为用户类型,则可以使用jQuery来完成此操作。但是你还不清楚决定文本框长度的因素,所以如果你想让文本框的大小随着用户类型的增加而增加,你可以使用这样的东西:
$('#abc').on('keyup', (function() {
var size = $(this).val().length();
$(this).css( 'width', size + 'px' );
});