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

117
Visualizações
jQuery for showing different text field showing when select two different items in selectbox

How to display the text fields when choosing different option from the selectoption (if select USA option USA text field need to show)?

<select name="cntry"> 
<option value="us">USA</option>
<option value="uk">uk</option>
</select >
<input type="text" value="USA" name="USA">
<input type="text" value="UK" name="UK">
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

$('#country').on('change', function() {
  $('input').each(function() {
    $(this).css('display', 'none');
  });
  if (this.value === 'us') {
    $('input[name="USA"]').css('display', 'initial')
  }
  if (this.value === 'uk') {
    $('input[name="UK"]').css('display', 'initial')
  }
});
input {
  display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select id="country" name="cntry">
  <option selected disabled hidden>Select your Country</option>
  <option value="us">USA</option>
  <option value="uk">uk</option>
</select>
<input type="text" value="USA" name="USA">
<input type="text" value="UK" name="UK">

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