S
S
shynga2020-04-27 15:46:48
JavaScript
shynga, 2020-04-27 15:46:48

How to remove option in select when selecting?

I would like to know how to remove the select option'y when choosing.
That is 3 select'а in which 3 identical option.
It is necessary that when an option is selected in one select in another, it disappears.
So that there is no 2nd choice of the same option.
5ea6d40391ea0832873521.jpeg
5ea6d414324b8649702243.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Sharomet, 2020-04-27
@sharomet

So?

<select class="sel">
  <option class="opt1">Option 1</option>
  <option class="opt2">Option 2</option>
  <option class="opt3">Option 3</option>
</select>
<select class="sel">
  <option class="opt1">Option 1</option>
  <option class="opt2">Option 2</option>
  <option class="opt3">Option 3</option>
</select>
<select class="sel">
  <option class="opt1">Option 1</option>
  <option class="opt2">Option 2</option>
  <option class="opt3">Option 3</option>
</select>

$('.sel').on('change', function() {
  $('.sel').not(this).find('.' + $(':selected', this).attr('class')).remove();
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question