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

210
Visualizações
jquery selector to get all select dropdowns with a particular value selected

How do I select all the select boxes using a jQuery selector where value selected is "A1"?

Sample select box:

<select name="accesslevel">
<option value="A1">A1 Access</option>
<option value="A2">A2 Access</option>
</select>

I have to use the selector to do the following thing:

.parent().nextAll('td[id^="A1Access"]').show();
.parent().nextAll('td[id^="A2Access"]').hide();

Can anyone help?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

As mentioned before, Prakash's solution is the closest, but it selects the option value rather than the select box itself. This can be fixed with the :has selector.

$('select:has(option[value="A1"]:selected)')
over 4 years ago · Santiago Trujillo Relatório

0

Try :

$('select option[value="A1"]:selected')
over 4 years ago · Santiago Trujillo Relatório

0

$('select').filter(
function(){   
   if($(this).val()=="A1")
        return true;
    else
        return false;
}
)

you can add your function after this like

$('select').filter(
function(){   
   if($(this).val()=="A1")
        return true;
    else
        return false;
}
).parent().nextAll('td[id^="A1Access"]').show();
over 4 years ago · Santiago Trujillo 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