Replace Contents of HTML in a loop with a specified Interval

by barkkathulla 2014-08-08 16:12:05

<script type="text/javascript">
$(document).ready(function() {
    /*** to change widget in each 10 seconds ***/
    var init=0;
    function changeWidget() {
        init < 3 ? init++ : init = 1;
		/*** this is to increment number ***/
        eval('data' + init + '()');
    }
    setInterval(changeWidget, 400);//required Interval

    /*** Show/Hide Datas ***/
    function data1() {
        $('.cont_1').hide();
        $('.cont_2').show();
        $('.cont_3').hide();
    }
    function data2() {
        $('.cont_1').show();
        $('.cont_2').hide();
        $('.cont_3').hide();
    }
    function data3() {
        $('.cont_1').hide();
        $('.cont_2').hide();
        $('.cont_3').show();
    }
});
</script>

<div>
	<div class="cont_1" style="display:none;">
		Have a Nice Day
	</div>

	<div class="cont_2" style="display:none;">
		Good Luck
	</div>

	<div class="cont_3" style="display:none;">
		Very Nice
	</div>
</div>
OUTPUT:
Have a Nice Day
OR
Good Luck
OR
Very Nice
1624
like
0
dislike
0
mail
flag

You must LOGIN to add comments