我们有这个:
$("input[type=text]").on("change", function () {
if ($(this).val() != "") {
//Deshabilitar (disabled) todos los otros input text que no sean este (this)
} else {
$("input[type=text]").prop("disabled", "");
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
</div>
<div>
<input type="text" />
</div>
<div>
<input type="text" />
<input type="text" />
</div>
有一种方法
jQuery
叫做not。它的作用是从选择中删除传递给它的元素或选择器。在你的情况下,它可能是这样的:最好缓存所有输入,这样您就不会经常选择它们: