Texto rotativo com javascript puro

by Ivan Ferrer

HTML

<div id="el">
    <h1>TEXTO DE EXEMPLO 1</h1>
    <h1>TEXTO DE EXEMPLO 2</h1>
    <h1>TEXTO DE EXEMPLO 3</h1>
    <h1>TEXTO DE EXEMPLO 4</h1>
</div>

CSS

#el h1 {
  display:none;
}
#el h1.active {
  display:block;
}

JavaScript

(function(){
  var el = document.getElementById('el'), total = el.children.length, t = 1000, count=0;
     setInterval(function() {
        for (var j=0; j < total; j++) {
            el.children[j].removeAttribute("class");
        }
            el.children[count].setAttribute("class", "active");
            count++;
         if (count == total) {
            count=0;
         }
   }, t);
})();