Last array value repeating.

Status
Not open for further replies.

NSA

sudo apt-get thefuckout.tar.gz
Dec 9, 2011
715
86
Hello all,

I have a script which fades in & out each array value but the last one "Change me 3." seems to be displayed twice, can someone help me? I have pasted my code below.

HTML:
<script type="text/javascript">
var myFunctions = {
    one: function(){
        rotateTerm();
        myFunctions.one();
    }
}
 
var terms = ["Change me 1.", "Change me 2.", "Change me 3."]; //array of terms to rotate
function rotateTerm() {
    var ct = $("#rotate").data("term") || 0;
 
    if (ct == 4) {
        $("#rotate").data("term", 0)
        return;
    }
    $("#rotate").data("term", ct == terms.length ? 0 : ct + 1).text(terms[ct]).fadeIn().delay(6000).fadeOut(200, rotateTerm);
}
$(document).ready(function(){ 
  window.lol = myFunctions.one();{   
  } 
});
</script>
 
Status
Not open for further replies.

Users who are viewing this thread

Top