scroll - Get position of clicked element with jquery? -
i want scroll item view when it's clicked, cannot manage it's top position on click:
this i'm trying right now:
$( "section" ).click(function(e) { console.log("thing top: "+$(this).position().top); //$('html,body').animate({ scrolltop: 0 }, 'slow'); //return false; });
however same top position, matter element clicked. how can right?
try $(this).offset().top
gets position relative document rather parent
Comments
Post a Comment