Here is piece of code i am getting an error in the console, can anyone point out where i am doing it wrong ? thanks in advance.
var intervalID = setInterval(function() {
// every 4 seconds execute following
var visibleWord = document.getElementsByClassName('visible')[0],
nextWord = visibleWord.nextSibling;
// check if nextSibling is textnode (whitespace) - if so get next next sibling.
if (nextWord.nodeType == 3) nextWord = nextWord.nextSibling;
// if there is a next node
if (!(nextWord == null)) {
visibleWord.setAttribute('class', 'hidden');
nextWord.setAttribute('class', 'visible');
} else {
clearInterval(intervalID);
}
}, 4000)