.setAttribute(“禁用”,false);将可编辑的属性更改为false [英] .setAttribute("disabled", false); changes editable attribute to false
问题描述
这是我试过的:
JS函数: a 设置disabled属性[...]也改变editable属性 是一个明确定义的行为。 真正的问题在这里似乎是您要设置 或者直接设置该属性: I want to have textboxes related to radiobuttons. Therefore each radio button should enable it's textbox and disable the others. However when I set the disabled attribute of textbox to true, it changes the editable attribute too. I tried setting editable attribute true again but it did not work. This was what I tried: JS function: XUL elements:
a set the disabled attribute [...] changes the editable attribute too is intended an well-defined behaviour. the real problem here seems to be you're trying to set or set that property directly:
这篇关于.setAttribute(“禁用”,false);将可编辑的属性更改为false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ b $ pre $ function enable(id)
{
var eleman = document.getElementById(id);
eleman.setAttribute(disabled,false);
eleman.setAttribute(editable,true);
$ b $ p $ X b
pre> < radio id =pnolabel =123onclick =enable('ad')/>
disabled
元素是(自我解释)禁用,从而逻辑上不可编辑。所以:
$ b
禁用
到 false
通过 setAttribute()
期待。如果设置了 disabled
-attribute,则该元素将被禁用,与其值无关(因此, disabled =true
, disabled =disabled
和 disabled =false
全部做同样的事情:元素被禁用)。您应该删除完整的属性:
element.removeAttribute(disabled);
element.disabled = false;
function enable(id)
{
var eleman = document.getElementById(id);
eleman.setAttribute("disabled", false);
eleman.setAttribute("editable", true);
}
<radio id="pno" label="123" onclick="enable('ad')" />
<textbox id="ad" editable="true" disabled="true" flex="1" emptytext="asd" onkeypress="asd(event)" tooltiptext="" >
disabled
element is, (self-explaining) disabled and thereby logically not editable. so:
disabled
to false
via setAttribute()
wich doesn't do what you're expecting. an element is disabled if the disabled
-attribute is set, independent of it's value (so, disabled="true"
, disabled="disabled"
and disabled="false"
all do the same: the element gets disabled). you should instead remove the complete attribute:element.removeAttribute("disabled");
element.disabled = false;