<input type="text" id="subInputValue01" onChange="changeInputValue()"></input>
<input type="text" id="subInputValue02" onChange="changeInputValue()"></input>
//采用的是jQuery,不是JavaScript
function changeInputValue(){
var subInputValue01=$("#subInputValue01").val();
var subInputValue02=$("#subInputValue02").val();
if (subInputValue01!=""){ //第一个input框不为空,第二个无法输入
$("#subInputValue02").attr("disabled","disabled");
}else { //第一个input框为空,第二个移除disable
$("#subInputValue02").removeAttr("disabled")
}
if (subInputValue02!=""){
$("#subInputValue01").attr("disabled","disabled");
}else {
$("#subInputValue01").removeAttr("disabled")
}
}
//初始化
$(function () {
changeInputValue();
});
jQuery 两个input框 一个input输入内容,另外一个input无法输入
最新推荐文章于 2023-01-10 16:56:48 发布