Jump to content

fading div in and out


conan318

Recommended Posts

the div fades in and out once but if i press the button again it wont fade div a second time...

 

 

<script type="text/javascript">
var fadeEffect=function(){
return{
	init:function(id, flag, target){
		this.elem = document.getElementById(id);
		clearInterval(this.elem.si);
		this.target = target ? target : flag ? 100 : 0;
		this.flag = flag || -1;
		this.alpha = this.elem.style.opacity ? parseFloat(this.elem.style.opacity) * 100 : 0;
		this.si = setInterval(function(){fadeEffect.tween()}, 50);
	},
	tween:function(){
		if(this.alpha == this.target){
			clearInterval(this.si);
		}else{

			var value = Math.round(this.alpha + ((this.target - this.alpha) * .01)) + (1 * this.flag);
			this.elem.style.opacity = value / 100;
			this.elem.style.filter = 'alpha(opacity=' + value + ')';
			this.alpha = value

		}

	}

}

}();

 

 

</script>

Link to comment
https://forums.phpfreaks.com/topic/266318-fading-div-in-and-out/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.