I have five anchor elements in my navigation. I want to get index of clicked element with jQuery. I tried this code.
$('.navigation ul li a').click(function(e) {
e.preventDefault();
var el = $(this).index();
console.log(el);
})
But every time I get zero in console.
https://jsfiddle.net/2hg2fkda/ fiddle is here.
Any help will be appreciated. Thanks,
try this:
$('.navigation ul li').click(function(e) {
e.preventDefault();
var el = $(this).index();
console.log(el);
})
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments