I was searching a script to make a div to fade in and out, and found this question fade in and fade out in pure javascript without jquery
User bgoldst gave a nice solution that worked for me. But I would need the fade in-out to run in loop, not just once as stated by bgoldst's code. I'm totally new at JS and don't know how to get it to work, any suggestion?
EDIT: I have found a intermediate solution with Luke's suggestion and Kai's suggestions from Pure JavaScript fade in function
That is
<script type="text/javascript">
var div = document.getElementById("foo");
setInterval(function() {
div.style.transition="opacity 1.5s";
div.style.opacity=0;
}, 1500);
setInterval(function() {
div.style.transition="opacity 1.5s";
div.style.opacity=1;
}, 3005);
</script>
However, the fade in/out effect doesn't have a symmetric behaviour.