Mead Umandal
Mead Umandal

Reputation: 373

JQuery Full Page JS

I am using fullpage.js with PHP. I have this code:

$('#fullpage').fullpage({
anchors: ['homepage', 'aboutmepage'],
menu: '#menu',
onLeave: function(index, nextIndex, direction){
    ALERT anchors[1] here!

    // changeNav(nextIndex);
}}

I need to alert the content of anchors based on an index. I don't know how. I've tried $('anchors')[0] but it did not work. Thanks in advance.

Upvotes: 1

Views: 121

Answers (1)

Alvaro
Alvaro

Reputation: 41595

Just do this:

onLeave: function(index, nextIndex, direction){
    //anchor of the leaving section
    alert( $(this).attr('data-anchor') );

   //anchor of the destination section
   alert( $('.fp-section').eq(nextIndex - 1 ).attr('data-anchor') );
}

Upvotes: 1

Related Questions