title: Fade in an image in javascript not working
body: <p>I'm trying to fade in an image, but it doesn't work. I found this post:
  <a href="https://stackoverflow.com/questions/3942727/javascript-fade-image-in-and-out/3943425#3943425">Javascript fade image in and out</a>
  And tried the following code, but no luck :(</p>
  
  <pre><code>var anImage= new Image();
  anImage.src='images\\anImage.gif'
  
  jQuery(function(){$("anImage").fadeIn()})
  anImage.fadeIn()
  </code></pre>
  
  <p>But I get the "Uncaught TypeError: Object # has no method 'fadeIn'" error.
  I must be doing something wrong. But I'm not seeing it :s. 
  Please help,</p>
  
  <p>Thanks in advance</p>
  
  <p>==================================================================================
  My code looks now like this:  </p>
  
  <pre><code>var deadImg=      new Image();
  deadImg.src='images/dead.gif'
  deadImg.id= 'imageID'
  deadImg.style.display = 'none'
  jQuery('body').append(deadImg);
  </code></pre>
  
  <p>And I wrote a function, which should draw the image (fade it in on the canvas)</p>
  
  <pre><code>function deadScreen(){
  GameOverSound.play();
  jQuery('#deadImg.id').fadeIn();
  }
  </code></pre>
  
  <p>But nothing is really happening. Am I doing something wrong?</p>
  
  <p>==================================================================================</p>
  
  <p>EDIT3:</p>
  
  <pre><code>function deadScreen(){
     GameOverSound.play();
  
  
     //increase the context.globalAlpha 0% -&gt;100% and draw image
     context.globalAlpha= 0%-&gt;100%
     context.drawImage(deadImg,0,0,canvas.width,canvas.height);
  
  
    //at the end make sure nothing is transparant!
    context.globalAlpha=1
  }
  </code></pre>
  
  <p>Can I do something like this? I thought using a for loop or something to increase transparancy from full transparant to not transparant. And with each step, redraw the image. Or isn't this a good idea?</p>
  
  <p>============================================================================</p>
  
  <p>Thank you everybody for your help. I solved the problem by increasing the globaltransparancy and redrawing the image. This is without jQuery and inside the canvas.</p>
  
  <p>But still thank you very much to the people who helped me :)</p>