我想要两个文本框字段的只读属性。单击“#text1”时,“#text2”应具有 false readonly 属性,而单击“#text2”时,“#text1”只读属性将为 false。默认情况下,两个文本框都具有真正的只读。可能吗?
<input type="text" id="text1" />
<input type="text" id="text2" />
最佳答案
试试这个:
$('#text1').focus(function(){
$('#text2').attr('readonly',true);
$('#text1').attr('readonly',false);
});
$('#text2').focus(function(){
$('#text1').attr('readonly',true);
$('#text2').attr('readonly',false);
});
关于javascript - 在文本框的情况下,readOnly 属性可以是切换形式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36147208/