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

77
Visualizações
Cambiar el campo de selección selectedIndex en el campo filtrado

Mi campo de selección se filtra de la siguiente manera:

 $("#asortyment option").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1); });

Para cambiar la opción seleccionada, uso el código:

 function wiecej(){ var asort_select = document.getElementById("asortyment"); asort_select.selectedIndex = asort_select.selectedIndex + 1; $("#asortyment").trigger("change"); };

Pero el problema es que la función wiecej cambia la opción a la siguiente pero no filtra la selección.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Use la pseudoclase jQuery :visible para hacer coincidir los elementos no filtrados. Y use :gt para comenzar después de la opción seleccionada actualmente.

 function wiecej() { var asort_select = document.getElementById("asortyment"); let current = asort_select.selectedIndex; let next = $(`#asortyment option:gt(${current}):visible`).first(); if (next.length > 0) { $(asort_select).val(next.val()).change(); } };

about 4 years ago · Juan Pablo Isaza Relatório

0

Filtre las opciones visibles y luego cambie el índice seleccionado:

 function wiecej(){ var asort_select = document.getElementById("asortyment"); var nextItem = $("#asortyment option:gt("+asort_select.selectedIndex+")").filter(function(){ return $(this).css('display') != 'none';}).first(); var nextIndex = 0; if (nextItem.length > 0 ) { nextIndex = nextItem[0].index; } else { var nextItem = $("#asortyment option").filter(function(){ return $(this).css('display') != 'none';}).first(); nextIndex = nextItem[0].index; } asort_select.selectedIndex = nextIndex; $("#asortyment").trigger("change"); };
about 4 years ago · Juan Pablo Isaza Relatório
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