I have this JS code:
function paging() {
$('.paging li').click(function(e) {
$('.paging li a').removeClass("active");
$(this).find('a').addClass("active");
$('#img-grp-wrap img').hide();
var indexer = $(this).index();
$('#img-grp-wrap img:eq('+indexer+')').fadeIn();
e.preventDefault();
return indexer;
});
}
var $cur_page = paging();
console.log($cur_page);
I would like to use the indexer value outside the function paging() but when I try doing console.log(), it just says undefined.
How do I structure this so that I can pass the index value of the link I clicked outside the function (which is the indexer variable)?
I'm a programming newbie so please bear with me.