Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

94
Vistas
How to get the language-picker button save the value after it is clicked with jquery cookie?

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.Here is the code I modified using jquery cookie plugin. I wanted to make my code check for cookies, and if there is one, set the cookie variable to div tag. Can someone show me how I can modify this code ?

$(document).ready(function(){
if($.cookie('lang-switch')!=null){
    $langCookie=$.cookie('lang-switch');
    $("#lang-menu div").html($langCookie);
}
$("#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
      var lang= $(this).html();
            $.cookie('lang-switch', lang)
        $("#lang-menu div").html(lang);
  });

});
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda