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

139
Visualizações
jQuery Selector set select value not working

I have a bootstrap modal, that is offers users to add or edit bank account data.

When I click "Edit" Btn to edit bank data, the modal will set the value to the input value and select the option.

But in the modal, I have two select options, top of the select is to choose bank code,

and when the select changes, it will trigger change function to use ajax to get branch bank list.

So if I want to set the value to the modal, the top select option (bank) can successfully set value,

but the bottom select option (branch) will not successfully set the value to the modal.

My code is:

// Set top select option
$('#selectBankList option[value='+bankName[0]+']').attr('selected','selected');

// Show Modal
addBankModal.show();

// getBranchList
f_getBranchList(bankName[0]);

$(document).ready(function() {
  // Set bottom select option
  $('#selectBranchName option[value='+branchName+']').attr('selected','selected');
});

I've to try putting the set #selectBranchName value to anywhere, but still not working.

So, where is my code wrong?

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

0

$('#selectBankList ').on('change', function(){
    $('#selectBranchName option[value="'+$(this).val()+'"]').attr('selected', 'selected').addClass('active');
});
about 4 years ago · Juan Pablo Isaza Relatório

0

$('#id attribute[foo="bar"]');

you have not added inner quotes

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