簡體   English   中英

設置readOnly = false IE后無法更改文本

[英]Can't change text after set readOnly=false IE

我有此示例代碼,並且它不能僅在IE中工作。 是否有IE錯誤?

<input type="text" readonly="true" onclick="setReadonlyfalse(this)" />

<script type="text/javascript">
    function setReadonlyfalse(ed){
        ed.readOnly = false;
    }
</script>

我正在模擬一種情況,在網格顯示編輯器后,我收到服務器的響應,將編輯器設置為readonly = false。 (它使用readonly = true呈現)

編輯:

我正在使用ExtJS 3.4,並且代碼執行此操作:

/**
 * Sets the read only state of this field.
 * @param {Boolean} readOnly Whether the field should be read only.
 */
setReadOnly : function(readOnly){
    if(this.rendered){
        this.el.dom.readOnly = readOnly;
    }
    this.readOnly = readOnly;
}

edit2 :我調整了代碼,使其更正確

<input type="text" readonly="readonly" onclick="removeReadonly(this)" value="hehehe" />
<script type="text/javascript">
    function removeReadonly(ed){
        ed.removeAttribute("readonly");
    }
</script>

以編程方式從元素中移除readonly屬性,然后將readOnly設置為false

ed.removeAttribute('readonly'); // only needed the first time
ed.readOnly = false;

是的,這是一個IE錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM