Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 类属性不适用于textBoxFor_Javascript_Css_Asp.net_Asp.net Mvc_Asp.net Mvc 5 - Fatal编程技术网

Javascript 类属性不适用于textBoxFor

Javascript 类属性不适用于textBoxFor,javascript,css,asp.net,asp.net-mvc,asp.net-mvc-5,Javascript,Css,Asp.net,Asp.net Mvc,Asp.net Mvc 5,我使用以下代码根据文本更改文本框的宽度 当前输入类型的工作正常 $(document).ready(function () { $('.myclass').css('width', (($('.myclass').val().length)+1) * 6 + 'px'); }); 这是正在工作的输入类型 <input type="text" class="myclass" disabled="disabled" style="margin-right: 5px;">

我使用以下代码根据文本更改文本框的宽度 当前输入类型的工作正常

$(document).ready(function () {
    $('.myclass').css('width', (($('.myclass').val().length)+1) * 6 + 'px'); 
});
这是正在工作的输入类型

<input type="text" class="myclass"   disabled="disabled" style="margin-right: 5px;">

您应该使用如下内容:

@Html.TextBoxFor(model => model.Service, new { disabled = "disabled", @class = "myclass"})

这是有效的。

您的
HTML.TextBoxFor
生成的HTML是什么?什么不起作用?如果宽度设置不正确?@RGraham这是html@StephenMuecke,宽度没有像在输入字段中一样发生相应的变化…@异常,请尝试添加另一个文本框,您将看到它不起作用
@Html.TextBoxFor(model => model.Service, new { disabled = "disabled", @class = "myclass"})