禁用属性在firefox中不起作用 - 对于div

时间:2011-05-20 15:56:29

标签: jquery html

亲爱的朋友们,你好 下面的代码在ie9中运行完美,但在firefox 3.6中不起作用

$('#ctl00_ContentPlaceHolder1_RadUploadImage').attr('disabled', 'disabled');

ctl00_ContentPlaceHolder1_RadUploadImage - >是一个div元素

当我们用firebug检查这个div时,表示我们禁用=“禁用”
但我有一个RadUpload Inside div正在工作!

html代码如下所示:

<div disabled="true" id="ctl00_ContentPlaceHolder1_RadUploadImage" class="RadUpload RadUpload_BlackByMe RadUpload_rtl RadUpload_BlackByMe_rtl" style="width: 325px;">
            <input autocomplete="off" id="ctl00_ContentPlaceHolder1_RadUploadImage_ClientState" name="ctl00_ContentPlaceHolder1_RadUploadImage_ClientState" type="hidden">
        <ul class="ruInputs" id="ctl00_ContentPlaceHolder1_RadUploadImageListContainer"><li><span class="ruFileWrap ruStyled"><input style="position: absolute; left: 0px; top: -5000px;" class="ruFileInput" size="23" dir="ltr" id="ctl00_ContentPlaceHolder1_RadUploadImagefile0" name="ctl00_ContentPlaceHolder1_RadUploadImagefile0" type="file"><input size="22" class="ruFakeInput" type="text"><input class="ruButton ruBrowse" value="select" type="button"></span><input name="ClearInput" class="ruButton ruClear" value="erase" id="ctl00_ContentPlaceHolder1_RadUploadImageclear0" type="button"></li></ul></div>

任何想法?

提前致谢

3 个答案:

答案 0 :(得分:10)

如果你正在使用jQuery&lt; 1.6做到这一点:

$('#ctl00_ContentPlaceHolder1_RadUploadImage').attr("disabled", 'disabled');

如果您使用的是jQuery 1.6 +:

$('#ctl00_ContentPlaceHolder1_RadUploadImage').prop("disabled", true);

请参阅此问题:.prop() vs .attr()以获取参考原因。

这里给出了相同的答案:jQuery .attr("disabled", "disabled") not working in Chrome

答案 1 :(得分:0)

答案 2 :(得分:0)

您不必使用JQ,只需使用纯JS:

document.getElementById('x').disabled = true;

或者如果你想要解决它:

document.getElementById('x').disabled = false;