How do I rotate images using javascript?
June 3, 2008 11:36 AM   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 answers total) 1 user marked this as a favorite
 
Best answer: 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, 2008


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


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, 2008


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


« Older Ordered X, got Y. Help?   |   If I Make This School Better, I Can Change the... Newer »
This thread is closed to new comments.