Skip to content

Instantly share code, notes, and snippets.

@lkptrzk
Last active January 1, 2016 20:59
Show Gist options
  • Select an option

  • Save lkptrzk/8200671 to your computer and use it in GitHub Desktop.

Select an option

Save lkptrzk/8200671 to your computer and use it in GitHub Desktop.
cycle background colors
$(function () {
function tick (str) {
indexs[str] = (indexs[str] + 1) % arrays[str].length
return arrays[str][indexs[str]]
}
var arrays = {}
arrays.colors = [
'yellow',
'red',
'blue'
]
var indexs = {}
indexs.colors = 0
function draw() {
$('body').css({
background: tick('colors')
})
}
setInterval(draw, 250)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment