Jump to content

appear image and disappear image


Pawan_Agarwal

Recommended Posts

I am trying to code something in Java-script, I am trying to "fade_in"  image and "fade_out" image with Set_interval function, I am facing problem, help me @@@@@

 

 

<html>
<script type="text/javascript">
var inc_bit =1e-2;
 
function inc_change()
{
var s = document.getElementById('img');
document.getElementById('write').innerHTML = inc_bit;
inc_bit = inc_bit + 1e-2;
s.style.opacity = inc_bit;
 
if(inc_bit>1e0)
{
setInterval(function() {dec_change();},100);
}
}
 
function dec_change()
{
var s = document.getElementById('img');
document.getElementById('write').innerHTML = inc_bit;
inc_bit = inc_bit - 1e-2;
s.style.opacity = inc_bit;
 
if(inc_bit<1e-2)
{
setInterval(function() {inc_change();},100);
}
}
setInterval(function() {inc_change();},90);
</script>
<body onload="inc_change()">
<img src="pic1.jpg" height="200px" width="250px" id="img" style="opacity:0.0"/>
<div id='write'></div>
</body>
</html>
Link to comment
https://forums.phpfreaks.com/topic/280270-appear-image-and-disappear-image/
Share on other sites

It gets turn into infinite loop and browser execution terminates, I am trying to perform a simple code

 

Just understand that I have a variable age and it gets incremented by one function called z1() now when age gets 18 it must call 2nd function called z2() that must start decreasing the age.............I think I am clear what I am trying to perform in the above code.......age is starting from 1 to 18 and then decreasing from 18 to 1 and this has to be achieved infinitely.......

 

I am trying to increase and decease the  opacity of image with time and I am facing some issue while handling the code..........

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.