Try something like this:
$(function(){
const branchChanged = function(){
let branch = $("#branch").val();
$("#warehouse").prop("disabled", branch !== "");
};
const warehouseChanged = function(){
let warehouse = $("#warehouse").val();
$("#branch").prop("disabled", warehouse !== "");
});
$("#branch").change(branchChanged);
$("#warehouse").change(warehouseChanged);
branchChanged();
warehouseChanged();
});
NB: Pay attention to the documentation:
jQuery offers several ways to attach a function that will run when the DOM is ready. All of the following syntaxes are equivalent:
$( handler )
$( document ).ready( handler )
$( "document" ).ready( handler )
$( "img" ).ready( handler )
$().ready( handler )
As of jQuery 3.0, only the first syntax is recommended; the other syntaxes still work but are deprecated.