-1

I have a select element with some options. The goal is to show part of HTML associated with the selected element. E.g: if I selected SP, document will show all the contacts registered to this id.

screen Here is the code:

<script language="javascript" type="text/javascript">
  $('#estado').change(function () {
  let zonas = $('.zonas'),
  selected = $('#estado').select().val(),
  dados = $('.dadosLoja'),
  dadosfiltro = $('.filtro'),
  filtro = document.getElementById(selected);
if (filtro == '' || filtro == null) {
  dadosfiltro.addClass('esconder');
  dados.removeClass('esconder');
} else {
  dadosfiltro.removeClass('esconder');
  dados.addClass('esconder');
  dadosfiltro.html(filtro);
}
});
</script>

All the options work fine and display the correct data onscreen. The trouble is when I want to select options that have already been selected. Filtro is returning null.

  • There is no event triggered when you click on previously selected option. In effect, nothing has changed. Also using `select()` for something it is not intended for – charlietfl May 07 '21 at 02:46

0 Answers0