Basic JavaScript Image Fading


/ Published in: JavaScript
Save to your folder(s)

adapted from:
[http://aktuell.de.selfhtml.org/artikel/javascript/fader-framework/bilderslideshow.htm](http://aktuell.de.selfhtml.org/artikel/javascript/fader-framework/bilderslideshow.htm)


Copy this code and paste it in your HTML
  1. function fade(step) {
  2. var imgs = document.getElementsByTagName("img");
  3. step = step || 0;
  4. imgs[1].style.opacity = step/100;
  5. imgs[1].style.filter = "alpha(opacity=" + step + ")";
  6. step += 2;
  7. if (step <= 100) {
  8. setTimeout(function() {
  9. fade(step);
  10. }, 1);
  11. }
  12. }

URL: http://jsfiddle.net/eXp5j/5/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.