JavaScript で disabled 属性の設定と削除を行う方法
JavaScriptでは、以下の方法で要素の disabled 属性を設定および削除できます。
- 「disabled」属性を設定する。
// 通过id获取元素,并设置disabled属性为true
document.getElementById("myButton").disabled = true;
- disabled属性を取り除く:
// 通过id获取元素,并移除disabled属性
document.getElementById("myButton").removeAttribute("disabled");
上記のコード内の”myButton”は、操作したい要素のidと置き換えてください。