Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

558
Vistas
Safari jquery select option .hide() alternative

I have a jquery script which at first hide all select options:

$('option[data-start="1"]').hide();

and then shows options based on user select of other input.

$('option[data-variable1="' + variable1x + '"][data-variable2="' + variable2x + '"]').show();

Everything works great, but on Safari .hide() doesn't work. I know about workaround:

$('option[data-start="1"]').prop('disabled', true);
$('option[data-variable1="' + variable1x + '"][data-variable2="' + variable2x + '"]').prop('disabled', false);

But this only turns off some options. I have dozens of options, so there is long list of inactive options. I tried hiding inactive options, but Safari probably ignores this code:

select option[disabled="disabled"]{display:none !important;width:0;height:0;visibility: hidden;opacity:0;}
select option:disabled { display:none !important;height:0;width:0;visibility: hidden;opacity:0;}

Could you help me with some workaround for Safari?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

to get a full browser compatible to hide and show elements try to use the hidden attribute https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden

to use it in your code to hide option

$('option[data-start="1"]').attr('hidden','hidden');

and to show an option use

$('option[data-start="1"]').removeAttr('hidden','hidden');

here a working fiddle https://jsfiddle.net/zj2kLxc8/1/

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda