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.
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.
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
posted by beerbajay at 12:52 PM on June 3, 2008
This thread is closed to new comments.
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