imagefader

I was asked to write a simple image fader. I believe I’ve come up with possibly the simplest one out there.

demo

To use this in your own site, link your document to a copy of the javascript and run imagefader_init() upon load, then edit the <img> that you want to run the fader on – here is an example:

<img
  src="/i/test1.png"
  class="imagefader /i/test1.png /i/test2.png /i/test3.png"
/>

That’s it!

4 Comments.

  1. Eh. Is the / character allowed as a class attribute values?

  2. probably not, but it works in real life, whether the specs say so or not.

  3. Looks good chap. The link to the javascript is broken – though I can grab it from the demo..

    cheers for that 🙂

    hostyle – If you are worried about the slashes you could replace them with some token and replace that when it comes time to use the class in the filepath

  4. thanks Mark. now that you’ve reminded me of it, I’ll upload the latest version (nothing major – just adds the current img src to the array so you don’t need to repeat it in the class). and I’ll fix that link. try again in five minutes.

%d bloggers like this: