August 30, 201115 yr Hello, As the title says i need to use javascript (or jquery) preferably javascript though to make an if statement for whether the jquery runs or not Ive looked on google etc but nothing answers my question, here is my jquery <script type="text/javascript"> var aImages = new Array(); var iPrev = -1; var iRnd = -1; aImages[0] = "http://canvasinabox.com/preview/7/47/47-7-preview_large.jpg"; aImages[1] = "http://canvasinabox.com/preview/7/48/48-7-preview_large.jpg"; aImages[2] = "http://canvasinabox.com/preview/7/46/46-7-preview_large.jpg"; aImages[3] = "http://canvasinabox.com/preview/18/133/133-18-preview_large.jpg"; aImages[4] = "http://canvasinabox.com/preview/27/174/174-27-preview_large.jpg"; aImages[5] = "http://canvasinabox.com/preview/27/173/173-27-preview_large.jpg"; aImages[6] = "http://canvasinabox.com/preview/5/25/25-5-preview_large.jpg"; $(document).ready(function() { /* Define the function that triggers to fade in the background as soon as the image has loaded */ $("img#bg").load(function() { /* Fade in during 3 seconds */ $("img#bg").fadeTo(3000,1); /* Set the timeout to fade out the image and the description after 10 seconds*/ setTimeout(function() { $("img#bg").fadeOut(3000); /* Load the next image after 4 seconds */ setTimeout(LoadImages,3000); } ,9000); } ) /* Start the slideshow one second after the page is ready */ setTimeout(LoadImages,1000); }); function LoadImage(iNr) { /* Assign the new image to the background */ $("img#bg").attr("src", aImages[iNr]); }; function LoadImages() { /* Select a random image number and make sure this is not equal to the previous image */ while(iPrev == iRnd) { iRnd = Math.floor(Math.random()*aImages.length); } /* Show the selected image */ LoadImage(iRnd); iPrev = iRnd; }; </script> and i need something like <script type="text/javascript"> if() { jquery goes here so it runs } else { some different jquery runs } </script> Any ideas? Thanks in advance
Create an account or sign in to comment