Here is the code:
Change number depending on how fast you want the colors to change
// var nIntervId;
function changeColor() {
nIntervId = setInterval(flashText, 100);
}
function flashText() {
var oElem = document.getElementById('my_box');
oElem.style.color = oElem.style.color == 'green' ? 'pink' : 'green';
// 'green' ? 'pink' : 'green' is a ternary operator.
}
function stopTextColor() {
clearInterval(nIntervId);
}
// end of loop
Here is an example of the demo in action: