I'd like to make a list about facts. When I click on the button the first fact should be replaced by the second and so on. But it doesn't work. Here is my code:
var facts = ['1. ', '2. ', '3. ', '4. '];
var print = document.getElementById('myfacts');
print.innerHTML = facts[0];
var i = 1;
function go() {
'use strict';
print.innerHTML = facts[i];
i = (i + 1) % (facts.length);
}
Here is my HTML:
<section id="fakten">
<div class="facts">
<h1>My 4 facts</h1>
<script src="facts.js"></script>
<p id="myfacts" class="myfacts"></p>
<a id="click" href="index.html" onclick="go();">Next</a>
</div>
</section>
But it doesn't work. Could you help me?