View Full Version : blending or fading div contents
Navarone
February 4th, 2009, 10:37 AM
How do I blend the contents of one div to another. I know you can blend images using javascript but is there anyway to blend the entire div contents? For example say you have 3 div's; one is shown by default the others are set to display:none. If I have a previous and next button, I can easily switch between the contents of the div. But I need a nice blending function.
Thanks
Navarone
February 5th, 2009, 10:59 AM
Ok, I came across some code on the internet and it works fairly well but I need some help modifing the code. First I have multiple div's; so how do I modify the code to pass different div id's when I click on a button? Second, is there anyway to have the div's start fading once the page is done loading? Here is the code.
function opacity(id, opacStart, opacEnd, millisec) {
var speed = Math.round(millisec / 100);
var timer = 0;
if(opacStart > opacEnd) {
for(i = opacStart; i >= opacEnd; i--) {
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
timer++;
}
} else if(opacStart < opacEnd) {
for(i = opacStart; i <= opacEnd; i++)
{
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
timer++;
}
}
}
function changeOpac(opacity, id) {
var object = document.getElementById(id).style;
object.opacity = (opacity / 100);
object.MozOpacity = (opacity / 100);
object.KhtmlOpacity = (opacity / 100);
object.filter = "alpha(opacity=" + opacity + ")";
}
DDD
February 5th, 2009, 01:41 PM
I think there are plenty of jquery plugins that will do this.
bigmtnskier
February 5th, 2009, 10:42 PM
Yeah, like DDD said... how about this?
http://jqueryfordesigners.com/image-fade-revisited/
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.