1
I’m trying to get the position of the links in 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 the 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 on the console
"Uncaught Typeerror: Cannot read Property 'top' of Undefined"
Thanks, it worked out here... Vlw!
– Helio