suteadd_1
02-21-2011, 06:55 AM
Hi, I need your help on Javascript and jQuery please!
First of all I was looking for a code which transit several background images according to the button you pressed. For example when you clicked on button 1 your background will be img1, and you clicked on button 2 on the same page the background image will be img2.
I could not find the exact code, however I found a similar one.
http://www.ovalpixels.com/bgImageTransition/
This transit images automatically according to the duration you choose and also has random maths, but I need your help to modify this so that this become onclick button event without random images.
Here's the code I found, and I added some extra <p> lines at bottom.
<head>
<title>BGTransition Demo</title>
<script type="text/javascript" language="javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.BgImageTransition.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div id="blaf"></div>
<script language="JavaScript" type="text/javascript">
$( function(){
var bgImages = [ 'Rosso Castilla.JPG', 'CRW_9620-R.jpg', 'CRW_9609 R.JPG' ];
var currImage = 'CRW_9620-R.jpg';
setInterval( function(){
do{
var randImage = bgImages[Math.ceil(Math.random()*(bgImages.length-1))];
}while( randImage == currImage )
currImage = randImage;
$('#blaf').BgImageTransition( 'img/'+currImage );
}, 5000)
})
</script>
<!--ADDED CODE-->
<p>
<a href="#bg1">button1 </a><br />
<a href="#bg2">button2 </a><br />
<a href="#bg3">button3 </a><br />
</p>
</body>
</html>
It would be much appreciated if you could reply me with a new code so that when you clicked the link the background will transit to different image.
For example, button1 = 'Rosso Castilla.JPG',
button2 = 'CRW_9620-R.jpg',
button3 = 'CRW_9609 R.JPG'.
thank you so much for your time and help!
First of all I was looking for a code which transit several background images according to the button you pressed. For example when you clicked on button 1 your background will be img1, and you clicked on button 2 on the same page the background image will be img2.
I could not find the exact code, however I found a similar one.
http://www.ovalpixels.com/bgImageTransition/
This transit images automatically according to the duration you choose and also has random maths, but I need your help to modify this so that this become onclick button event without random images.
Here's the code I found, and I added some extra <p> lines at bottom.
<head>
<title>BGTransition Demo</title>
<script type="text/javascript" language="javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.BgImageTransition.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div id="blaf"></div>
<script language="JavaScript" type="text/javascript">
$( function(){
var bgImages = [ 'Rosso Castilla.JPG', 'CRW_9620-R.jpg', 'CRW_9609 R.JPG' ];
var currImage = 'CRW_9620-R.jpg';
setInterval( function(){
do{
var randImage = bgImages[Math.ceil(Math.random()*(bgImages.length-1))];
}while( randImage == currImage )
currImage = randImage;
$('#blaf').BgImageTransition( 'img/'+currImage );
}, 5000)
})
</script>
<!--ADDED CODE-->
<p>
<a href="#bg1">button1 </a><br />
<a href="#bg2">button2 </a><br />
<a href="#bg3">button3 </a><br />
</p>
</body>
</html>
It would be much appreciated if you could reply me with a new code so that when you clicked the link the background will transit to different image.
For example, button1 = 'Rosso Castilla.JPG',
button2 = 'CRW_9620-R.jpg',
button3 = 'CRW_9609 R.JPG'.
thank you so much for your time and help!