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

134
Vistas
How to check with jquery if select has options?

How to check with jquery if select has options and if it doesn't to disable it and show [not items]?

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

One way to do to it:

if ($('#myselect option').length == 0) {
    $('#myselect').hide();
}
over 4 years ago · Santiago Trujillo Denunciar

0

var $select = $('input:select option');
if(!$select.length )
    $select.attr('disabled', true);

Or:

$('select:not(:has(option))').attr('disabled', true);
over 4 years ago · Santiago Trujillo Denunciar

0

Another way to do it is simply use the jQuery has function

if ($('#myselect').has('option').length == 0) 
{
    // Hide and disable select input here
}

For information on the jQuery has function see: https://api.jquery.com/has/

over 4 years ago · Santiago Trujillo 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