Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
Unable to hide/show <select> options on Safari, but works fine on Firefox and Chrome

I have a parent Dropdown, and a child Dropdown on my page. When I change the option on the parent Dropdown, some of the options shown on the child dropdown should hide, and only the appropriate options should show. The code that I have works as desired on Chrome and Firefox, but not on Safari Browser.

Upon debugging from Safari Console, I find the hidden class is getting removed from the appropriate <option></option>, but the options in the child-dropdown are not getting hidden. Similarly, when I select 'All' option from the parent dropdown, all the options from the child dropdown are getting hidden class removed from them; and when I select any other option, the options in the child dropdown that earlier did not have hidden (were displayed), which now need to be hidden, now have the hidden class added to them. But this is not showing/displaying on the UI.

This is from Safari console. As shown here... hidden class has been added to the option, but the option is still visible, and selectable on the UI.

hidden class has been added to the option, but the option is still visible, and selectable on the UI.

I have seen some other similar issues posted on StackOverflow, and on other blogs, where it is suggested to disable the option, rather than hide. My issue is that, since this is a Browser specific issue, and since it is working on all other browsers excepts Safari, I would want to avoid changing the functionality.

This is what I have so far =>

form.jsp

...
...
<select class="form-control" onchange="toggleDropdowns(this.value)">
    <option value="">All</option>
    <c:forEach items="${items.rows}" var="set">
        <option value=".${set.id}">${set.nm}</option>
    </c:forEach>
</select>
....
....

JS Function

toggleDropdowns : function(id) {
    $(".inactive .set-option").addClass("hidden");
    $(".inactive .set-option" + id).removeClass("hidden");
}

Update

I have tried other ways of hiding/showing the option as well, like using .css({display:none});. This too works on Firefox and Chrome, but not on Safari.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda