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

186
Visualizações
jQuery changes select value but doesn't trigger page refresh

I created radio buttons on mobile that need to trigger the hidden select option in order for the page to refresh. I have this code and it does change the select value on radio button click, but it doesn't refresh the page. When I click on it with my mouse the page refreshes with the selected option, but not when I do it just with jQuery. What can I do about it?

Radio buttons:

<div class="m-box">
<input type="radio" class="sort-radio" name="r" value="featured">
<label>Featured Items</label>
<input type="radio" class="sort-radio" name="r" value="newest">
<label>Newest Items</label>
<input type="radio" class="sort-radio" name="r" value="bestselling"><label>Best 
Selling</label>
</div>

Select:

<select class="form-select form-select--small " name="sort" id="sort" role="listbox">
    <option value="featured" selected="">Featured Items</option>
    <option value="newest">Newest Items</option>
    <option value="bestselling">Best Selling</option>
</select>

Code:

$(".sort-radio").change(function () {                
$("#sort")
        .val($(this).val())
        .trigger('change');
});

I tried trigger('change') and change()...it does change the select option value, but how can I "fake" a mouse click in order for the whole page to refresh?

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

0

$(".sort-radio").change(function() {

$("#sort").val($(this).val()).trigger('click');

});

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