數,我試圖讓FULLPAGE.JS獲取。主動幻燈片和更新每一個新的幻燈片
current slide/total slides
上Fullpage.js
,並得到更新,每次滑的改變當前幻燈片。
我是一個JavaScript的總新手,我試圖解決這個代碼。數字出現,但不會更新每次幻燈片更改。
$(function() {
var sections = $('.section');
updateCurrentIndex(); //on document.ready and on each slidechange
function updateCurrentIndex() {
sections.each(function() {
var section = $(this),
sectionSlides = section.find('.slide'),
totalItems = sectionSlides.length,
currentIndex = sectionSlides.filter('.active').index() + 1,
numContainer = section.find('.num'); //assuming you have numContainers in every section
numContainer.html("0" + currentIndex + '/' + totalItems);
});
}
});
任何幫助將大大apprciated。
https://jsfiddle.net/0hLzxrea/66/
感謝@Alvaro,我剛剛更新了我的小提琴,它看起來像它不工作https://jsfiddle.net/0hLzxrea/68/ – Federico
的.num是在部分,而不是像我之前那樣在幻燈片中。看看這裏:https://jsfiddle.net/0hLzxrea/69/也更新了答案。 – Alvaro
非常感謝你@阿爾瓦羅,你讓我的一天! 只是一個快速的,如果.num在#fullpage之外怎麼辦?有沒有簡單的方法來查找和更新它? – Federico