与标题相同。
const inputs =document.querySelectorAll('input');
inputs.forEach(function(_inputs){
_inputs.readOnly = !_inputs.readOnly;
if(_inputs.readyOnly == false){
_inputs.classList.remove("readOnlyItem")
_inputs.classList.add("notReadOnly")
}else if(_inputs.readyOnly == true){
_inputs.classList.add("readOnlyItem")
_inputs.classList.remove("notReadOnly")
}
});
据我所知,每件事似乎都是正确的,应该可以正常工作,但 if 语句由于某种原因永远不会返回 true。