I'm trying to get the position of links from a menu and I'm not getting
<nav class="menu">
<ul class="nav">
<!-- <span><a href=""><img src="cds.jgp" alt="Logo Cetec"></a></span> -->
<li><a href="#home">Home</a></li>
<li><a href="#servicos">Serviços</a></li>
<li><a href="#empresa">Empresa</a></li>
<li><a href="#clientes">Clientes</a></li>
<li><a href="#social">Social</a></li>
<li><a href="#news">News</a></li>
<li><a href="#comentarios">Comentários</a></li>
</ul>
</nav>
Using jQuery
$('a').click(function(){ return false; });
$('.nav li a').click(function(){
//$('.nav li a').removeClass('active');
//$(this).addClass('active');
var getlink = $(this).attr("href");
var getpos = $(getlink).position().top;
console.log(getpos);
return false;
});
Only this message appears in the console
"Uncaught TypeError: Can not read property 'top' of undefined"