Jump to content

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..........

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.