So far the best solution for me (based on Jezen Thomas solution) is to set on focus
readonly
to input
s and textarea
s and disabled
to select
s, and remove them on blur
:
jQuery('input, textarea, select').on('focus', function() {
jQuery('input, textarea').not(this).attr("readonly", "readonly");
jQuery('select').not(this).attr("disabled", "disabled");
});
jQuery('input, textarea, select').on('blur', function() {
jQuery('input, textarea').removeAttr("readonly");
jQuery('select').removeAttr("disabled");
});
Only one flaw is that you need to drop focus (for example clicking on background) before changing from input
/ textarea
to select. But you can easily change your focus between input
s and textarea
s.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…