I've been searching but I couldn't find anything that helps me.
I have a file countdown.js app/assets/javascript/countdown.js
// Total seconds to wait
var seconds = 11;
function countdown() {
seconds = seconds - 1;
if (seconds < 0) {
// Chnage your redirection link here
seconds = 11;
window.setTimeout("countdown()", 1000);
} else {
// Update remaining seconds
document.getElementById("countdown").innerHTML = seconds;
// Count down using javascript
window.setTimeout("countdown()", 1000);
}
}
// Run countdown function
countdown();
And I want to call this function on my index.html.erb file. What should I do?
<script src="countdown.js"></script>if that does not work make sure you specify the correct path