We have a asp.net mvc application where we have to disable mvc html controls within a css class which works fine in IE browser but it does not work in Chrome and Firefox.
我们有一个asp.net mvc应用程序,我们必须在css类中禁用mvc html控件,这在IE浏览器中工作正常,但它在Chrome和Firefox中不起作用。
This is the code we use at the moment:
这是我们目前使用的代码:
$(".q-answer").attr("disabled", "disabled");
We have tried to disable with prop and also different options but it didn't work.
我们已尝试禁用prop和不同的选项,但它不起作用。
Please see below code from developer tools:
请参阅下面的开发人员工具代码:
IE browser :
IE浏览器:
<p **disabled="disabled"** class="q-answer">
<select name="QuestionnaireResponses.IsAvailableForReview" id="ddlIsAvailableForReview" onchange="IsAvailableForReview()">
<option value="">Select</option>
<option selected="selected" value="Y">Yes</option>
<option value="N">No</option>
</select>
</p>
Chrome Browser :
Chrome浏览器:
<p class="q-answer">
<%: Html.DropDownListFor(m => m.QuestionnaireResponses.IsAvailableForReview, new SelectList(yesNoOptions, "Value", "Text"), "Select", new { @id = "ddlIsAvailableForReview", onChange = "IsAvailableForReview()" })%>
</p>
If you see both elements from browsers, IE works fine as it adds disabled property but for Chrome it doesn't add.
如果您从浏览器中看到这两个元素,IE可以正常工作,因为它添加了禁用属性,但对于Chrome它不会添加。
Any help is appreciated.
任何帮助表示赞赏。
1 个解决方案
#1
0
Use prop()
for jquery versions 1.6+
将prop()用于jquery版本1.6+
$(".q-answer").prop("disabled", true)
or you can use the following in any case this.disabled = true
或者你可以在任何情况下使用以下this.disabled = true
$(".q-answer").each(function(){
this.disabled = true;
})
#1
0
Use prop()
for jquery versions 1.6+
将prop()用于jquery版本1.6+
$(".q-answer").prop("disabled", true)
or you can use the following in any case this.disabled = true
或者你可以在任何情况下使用以下this.disabled = true
$(".q-answer").each(function(){
this.disabled = true;
})