Created
July 6, 2014 15:34
-
-
Save mbaljeetsingh/beb9ab765c963944f7e2 to your computer and use it in GitHub Desktop.
Cycle through two divs jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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