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

204
Visualizações
How can I make the language-picker button save the value after it is clicked and the page is reloaded?

a JQuery newbie here.

The following jquery code for a language-picker (to be used on multi-language website, let's say) should show the active language clicked by user. The problem is that after the webpage reloads in the chosen language, the language picker defaults to the language in the div tag. It doesn't show the language picked by user.

I kind of tried setting up a cookie and doing something with it. But I couldn't make it work. How can I edit the code so that the language picker button shows the active language icon picked by user?

Here is the code in jquery. (the website backend/frontend is built in nodejs/ejs+jquery)

 $("#lang-menu").hover(
    function(){
        $(this).addClass("cls-border-lang");
        $(this).children().eq(0).addClass("cls-borderbottom-lang");
              $("#lang-menu ul").stop().slideToggle(100);
    },
    function(){
                $(this).removeClass("cls-border-lang");
        $(this).children().eq(0).removeClass("cls-borderbottom-lang");
        $("#lang-menu ul").stop().slideToggle(100);  
    }
  );
  /// click languages
  $("#lang-menu ul li").on("click", function(){
        //select lang and apply changes
      // $lang= $(this).html();
        $("#lang-menu div").html($lang);
  });
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you do not want to use cookies, you could store the default language in the Session Storage.

If you choose to go this route, you would have to edit your on-click handler to overwrite the selected language variable stored in your Session Storage and also edit your code that renders the selected language to always display what is stored in Session Storage.

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