Title on horizontal navigation bar with dots in fullpage.js

不打扰是莪最后的温柔 提交于 2019-12-13 04:47:45

问题


I am designing website using fullpage.js. I want to give title to each dot in horizontal navigation bar.

function addSlidesNavigation(section, numSlides){
        section.append('<div class="fp-slidesNav"><ul></ul></div>');
        var nav = section.find('.fp-slidesNav');

        //top or bottom
        nav.addClass(options.slidesNavPosition);

        for(var i=0; i< numSlides; i++){
            nav.find('ul').append('<li><a href="#"><span></span></a></li>');
        }

        //centering it
        nav.css('margin-left', '-' + (nav.width()/2) + 'px');

        nav.find('li').first().find('a').addClass('active');
}

function call from :

if(options.slidesNavigation){
    addSlidesNavigation($(this), numSlides);
}

This function generates horizontal navigation bar. I want to add title for each. I am not getting how do I do it. Please help.


回答1:


I did it by following way.

In index page: horizontalNavigationToolTip = ['tooltip1','tooltip2'],

in jquery.fullpage.js:

function addSlidesNavigation(section, numSlides){
        section.append('<div class="fp-slidesNav"><ul></ul></div>');
        var nav = section.find('.fp-slidesNav');

        //top or bottom
        nav.addClass(options.slidesNavPosition);

        for(var i=0; i< numSlides; i++){
            //nav.find('ul').append('<li><a href="#" title="'+ tooltip[i] +'"><span></span></a></li>');

            // Only add tooltip if needed (defined by user)
            var tooltip = options.horizontalNavigationToolTip[i];

            var li = '<li><a class="tooltips" href="#"><span></span><div><img src="images/tooltip/'+ tooltip +'.png" /></span></div></a>';
            li += '</li>';

            nav.find('ul').append(li);
        }

        //centering it
        nav.css('margin-left', '-' + (nav.width()/2) + 'px');

        nav.find('li').first().find('a').addClass('active');
    }

hope this is helpful to others.



来源:https://stackoverflow.com/questions/28318492/title-on-horizontal-navigation-bar-with-dots-in-fullpage-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!