Skip to content

Instantly share code, notes, and snippets.

@mbaljeetsingh
Created July 6, 2014 15:34
Show Gist options
  • Save mbaljeetsingh/beb9ab765c963944f7e2 to your computer and use it in GitHub Desktop.
Save mbaljeetsingh/beb9ab765c963944f7e2 to your computer and use it in GitHub Desktop.
Cycle through two divs jquery
<div style="text-align: center">
<span id="block1" style="font-size: 200px;color:#FF0000">ਵਾਹਿ</span>
<span id="block2" style="font-size: 200px; margin-left: 125px; color:#FF0000">ਗੁਰੂ</span>
</div>
<script>
jQuery(document).ready(function($) {
var shortIntervalTime = 1 * 200;
var longIntervalTime = 1 * 500;
function cycle(id) {
var nextId = (id == "block1") ? "block2": "block1";
$("#" + id)
.delay(shortIntervalTime)
.fadeIn(100)
.delay(shortIntervalTime)
.fadeOut(100, function() {cycle(nextId)});
}
cycle("block1");
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment