Hi there,
Im just trying to display a random div on load.
I have adapted someone elses code to try and make it work for divs (was originally for changing background)
Can anyone see why it isnt working for me?
the divs are both hidden on load
- $(document).ready(function(){
- var randomNum = Math.ceil(Math.random()*2);
- var number = null;
- $.each([1,2], function(){
- number = randomNum;
-
- if( number !== 1 ) {
- ('#randomdiv1').show();
- } else {
- ('#randomdiv2').show();
- }
- });
- })
- this is what i also tried...
- $(document).ready(function(){
- var randomNum = Math.ceil(Math.random()*2);
- if( randomNum !== 2 ) {
- ('#randomdiv1').fadeIn('slow');
- } else {
- ('#randomdiv2').fadeIn('slow');
- }
- });
cheers!