I can’t figure out why this is not working. I’m trying to get different DIV tags to have different text content in a cycle loop.
<script type="text/javascript"> var text1 = ['foo', 'bar', 'baz']; var i1 = 0, var text2 = ['hug', 'kiss001', 'bank22']; var i2 = 0, $(document).ready(function() { setInterval(function (){ $("#DIV1").fadeOut(function () { $("#DIV1").text(text[i1++ % text1.length]).fadeIn(); }); }, 1000); setInterval(function (){ $("#DIV2").fadeOut(function () { $("#DIV2").text(text[i2++ % text2.length]).fadeIn(); }); }, 1000); }); </script>
<div id="DIV1"><div>
<div id="DIV2"><div>
Seems to be a bunch of syntax errors (
textinstead oftext1/text2, no closing /div, etc. Works fine here: http://jsbin.com/obaqi4/3