Skip to content

Instantly share code, notes, and snippets.

@guert
Created April 12, 2012 21:38
Show Gist options
  • Save guert/2371179 to your computer and use it in GitHub Desktop.
Save guert/2371179 to your computer and use it in GitHub Desktop.
Display Random Div
<div id="rd1">
ONE
</div>
<div id="rd2">
TWO
</div>
<div id="rd3">
THREE
</div>
<script type="text/javascript" language="JavaScript">
randomNumber = Math.floor(Math.random()*4+1);
window.onload = function() {
if (randomNumber == 1) {
document.getElementById("rd1").style.display = "inline";
document.getElementById("rd2").style.display = "none";
document.getElementById("rd3").style.display = "none";
}
if (randomNumber == 2) {
document.getElementById("rd1").style.display = "none";
document.getElementById("rd2").style.display = "inline";
document.getElementById("rd3").style.display = "none";
}
if (randomNumber == 3) {
document.getElementById("rd1").style.display = "none";
document.getElementById("rd2").style.display = "none";
document.getElementById("rd3").style.display = "inline";
}
}
//--></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment