const $select = $('select').change(function() {
const selected = $(':selected', this).get().map(n => n.value);
const disabled = $(':disabled', this).get().map(n => n.value);
$select
.not(this)
.find('option')
.prop('disabled', function(i, val) {
return disabled.includes(this.value) ? val : selected.includes(this.value);
});
});
или
const selects = [...document.querySelectorAll('select')];
selects.forEach(n => n.addEventListener('change', onChange));
function onChange() {
const options = [...this];
const selected = options.filter(n => n.selected).map(n => n.value);
const disabled = options.filter(n => n.disabled).map(n => n.value);
for (const n of selects.flatMap(m => m === this ? [] : [...m])) {
n.disabled = disabled.includes(n.value) ? n.disabled : selected.includes(n.value);
}
}