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

364
Vistas
JQuery why does .offset() not return value?

Hi i get a JS error in my browser inspector. But i dont understand whats wrong with my Jquery code. And why he consider this variable as undefined ... Could someone help me ?

The code works well; but i would prefer to remove the error: Uncaught TypeError: varposlist is undefined

This is my js code:

 $(function(){
var pane = $('.scroll-pane');
pane.jScrollPane({
    });
var api = pane.data('jsp');

    if(typeof localStorage!='undefined') {
        //Get var from local storage
        var menu = sessionStorage.getItem("menu");
        var yposistock_rule = sessionStorage.getItem("yposistock_rule");
        

        //Check menu view mode
        if(menu == "arbo") {
            // defined top from a#on anchor
            var varposchapter = $('a#on_menuchapter').offset();
            //add - 285 to put at same level than title
            var vartop1 = varposchapter.top -285 -yposistock_rule;
            if(scrollauto_rule == "oui") {
                sessionStorage.removeItem("yposistock_rule");
            };
            api.scrollTo(0, vartop1);
            return false;
             
        }
        else{   
            // defined top from a#on anchor
            var varposlist = $('a#on_menulist').offset();
            //add - 285 to put at same level than title
            var vartop2 = varposlist.top -285 -yposistock_rule;
            if(scrollauto_rule == "oui") {
                sessionStorage.removeItem("yposistock_rule");
            };
            api.scrollTo(0, vartop2);
            return false;
        }
    }
});

Any idea ? Thanks a lot.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The only thing I can think of is this line:

$('a#on_menulist').offset();

The # selects the element with the same ID. Unless you have an element with id=on_menulist, this code cannot find the id which then cannot find the offset.

about 4 years ago · Juan Pablo Isaza Denunciar
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