如何禁用并重新启用JavaScript中的按钮? [英] How do I disable and re-enable a button in with javascript?
问题描述
我可以轻松禁用一个javascript按钮,并且它可以正常工作。我的问题是,当我尝试重新启用该按钮时,它不会重新启用。以下是我正在做的事:
< script type =text / javascript>
函数startCombine(startButton){
startButton.disabled ='true';
startButton.disabled ='false';
}
< / script>
< input type ='button'id ='start'value ='合并所选视频'
onclick ='startCombine(this);'>
为什么不能正常工作,我该怎么做才能使它工作?
您希望文字 类型的原因(禁用元素)是因为非空字符串是 truthy 。因此,将 I can easily disable a javascript button, and it works properly. My issue is that when I try to re-enable that button, it does not re-enable. Here's what I'm doing: Why isn't this working, and what can I do to make it work? You want the literal The reason it sort of works (disables the element) is because a non empty string is truthy. So assigning 这篇关于如何禁用并重新启用JavaScript中的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! true 和
false
在这种情况下并不意味着是字符串。
真
和 false
布尔值
值。
startButton.disabled = true;
startButton.disabled = false;
'false'
分配给 disabled
属性具有将它设置为 true的相同效果
。<script type="text/javascript">
function startCombine(startButton) {
startButton.disabled = 'true';
startButton.disabled = 'false';
}
</script>
<input type='button' id='start' value='Combine Selected Videos'
onclick='startCombine(this);'>
true
and false
are not meant to be strings in this context. true
and false
Boolean
values.startButton.disabled = true;
startButton.disabled = false;
'false'
to the disabled
property has the same effect of setting it to true
.