How do I rotate images using javascript?
June 3, 2008 11:36 AM   RSS feed for this thread Subscribe

Having trouble with javascript. How do I rotate two images using javascript?

I might be going about this all wrong, since I'm having trouble getting this to work. I've searched google but can't find anything thats close enough to what I'm doing.

All I need to do is have two images rotate on a web page. One of the images needs to be clickable to a url, and the other should have no link.

Ideally I'd like to have two div's with ID's that swap, but thats not important if thats not the best way.

I tried to use this as a guide, but ran into problems since I don't want one of the images to be clickable.
posted by eightball to computers & internet (4 comments total) 2 users marked this as a favorite
I haven't tested the code but I found this example that seems to do what you want.

If it doesn't, let me know. I have a JS book at home that has a script for this in it, but I'm obviously not at home :)
posted by arniec at 12:10 PM on June 3


That did the trick - thanks!
posted by eightball at 12:51 PM on June 3


You can easily do this with DOM manipulation. You should target a parent element, like a div or whatever with an id (use getelementbyid), delete its children, then add the necessary anchor and img elements each time you rotate.
posted by beerbajay at 12:52 PM on June 3


too late!
posted by beerbajay at 12:53 PM on June 3


« Older Spent $$ on wooden blocks with...   |   I'm looking for some research ... Newer »

You are not logged in, either login or create an account to post comments



Related Questions
Help me AJAXify a portion of my project without... January 8, 2008
Looking for web-dev book suggestions February 8, 2007
Mark CF, if you're reading this, shoo! January 23, 2007
What's the step BEFORE "newbie" called? January 4, 2007
Your favorite web design tricks? March 16, 2006