I am trying to pass a variable to go to a certain url when I click a button. It is a clickfunnels member's area with lessons and I managed to go to the previous / next lesson. It also works if I specify a specific lesson like for instance #4-1.
However, I am now trying to pass a variable so that the link redirect to whichever lesson is specified in the url (which would be in the form of #section-lesson)
<script>
$(function() {
var lessonLinks = $("a.lesson-link[id!='temp-link']");
var idx = [];
lessonLinks.each(function(i) {
idx[i] = this.id;
});
$(document).on("click","a[href='#next-lesson']",function (ev) {
ev.preventDefault();
var currIndex = $.inArray($('a.activeMemberNav').attr("id"),idx);
$('a.lesson-link[id="'+idx[currIndex+1]+'"]').click();
window.scrollTo(0,0);
});
$(document).on("click","a[href='#previous-lesson']",function (ev) {
ev.preventDefault();
var currIndex = $.inArray($('a.activeMemberNav').attr("id"),idx);
$('a.lesson-link[id="'+idx[currIndex-1]+'"]').click();
window.scrollTo(0,0);
});
$(document).on("click","a[href='#3-1']",function (ev) {
ev.preventDefault();
var currIndex = $.inArray($('a.activeMemberNav').attr("id"),idx);
$('a.lesson-link[id="3-1"]').click();
window.scrollTo(0,0);
});
$(document).on("click","a[href='#lesson']",function (ev) {
ev.preventDefault();
var currIndex = $.inArray($('a.activeMemberNav').attr("id"),idx);
$('a.lesson-link[id="#lesson"]').click();
window.scrollTo(0,0);
});
});
</script>