initial
This commit is contained in:
20
nav.js
Normal file
20
nav.js
Normal file
@@ -0,0 +1,20 @@
|
||||
(function(){
|
||||
var idx = 0;
|
||||
var bck = document.getElementById("bck");
|
||||
var fwd = document.getElementById("fwd");
|
||||
|
||||
bck.addEventListener('click', function() { idx--; show(); });
|
||||
fwd.addEventListener('click', function() { idx++; show(); });
|
||||
|
||||
function show() {
|
||||
var poems = document.getElementsByClassName("poem");
|
||||
|
||||
if (idx < 0) idx = poems.length-1;
|
||||
if (idx >= poems.length) idx = 0;
|
||||
|
||||
for (var i = 0; i < poems.length; i++) poems[i].style.display = "none";
|
||||
|
||||
poems[idx].style.display = "block";
|
||||
}
|
||||
show(idx);
|
||||
})();
|
Reference in New Issue
Block a user