代码之家  ›  专栏  ›  技术社区  ›  newdayrising

FireFox对禁用字段的处理

  •  1
  • newdayrising  · 技术社区  · 15 年前

    谢谢

    5 回复  |  直到 15 年前
        1
  •  1
  •   newdayrising    15 年前

    我能够通过使用jQuery设置和删除禁用的属性而不是直接设置它来解决这个问题。我不确定它在引擎盖下做了什么来让它工作。

    $(control).attr('disabled', 'disabled');
    $(control).removeAttr('disabled');
    
        2
  •  1
  •   Leo user370469    13 年前

    在我头昏脑胀了4个小时之后,以下是对我有效的方法:

    document.getElementById(ID).disabled = true|false;                // this works only in IE
    document.getElementbyId(ID).setAttribute('disabled', true|false); // This works both in IE\FF
    
        3
  •  0
  •   Diodeus - James MacFarlane    15 年前

    为我工作:

    <select id="a" disabled="true">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    </select>
    
    <script type='text/javascript'>
    document.getElementById('a').disabled=false
    </script>
    
        4
  •  0
  •   Kj.    15 年前

    
        function edit(ID) {
            // need to add previous field code and set disabled to true
            document.getElementById(ID).disabled=false
            document.getElementById(ID).focus();
        }
    
    
    

    //开始正文代码

    <form name="theform"><table><tr><td><span style="padding:5px;border:1px solid black;" onclick="edit('myId1');"><input  onclick="edit();"   disabled id="myId1" type="text"" value="Value One" /></span></td></tr></form>
    

    //端体代码

        5
  •  0
  •   Promethius    15 年前

    我一直用。。。

    document.getElementById(ID).disabled=“disabled”

    ……还有。。。

    …而不是真/假。你试过了吗?