We have this:
$("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>
There is a method
jQuery
called not . What it does is remove the element or selector you pass to it from the selection. In your case it could be like this:It's best to cache all the inputs so you're not constantly selecting them: