Bar that changes from time to time

0

Well, I have a little bar here on my site

<div style="padding: 30px;" class="bg-light-gray" id="barra- programas"></div>

I want to use JS to make every 10 seconds it changes text, in

/sistemas/frases.php 

When it comes it comes with a different phrase, every 10 seconds I want js to take a phrase from there and put it on the bar, deleting the previous message.

    
asked by anonymous 09.05.2016 / 22:25

1 answer

2

You can do this:

var bar = ['texto 1', 'texto 2', 'texto 3'];
var start = 0;

function foo() {
  if (start == bar.length) {
    start = 0;
  }
  document.getElementById('qux').innerHTML = bar[start];
  start++;
}

setInterval(foo, 1000);
#qux {
  background: black;
  color: white;
  font-size: 40px;
  text-align: center;
}
<div id="qux"></div>
    
09.05.2016 / 22:49