Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouseover a dynamically positioned image 1

Status
Not open for further replies.

greggb

Programmer
Dec 6, 2003
30
US
I need to make a dynamically positioned image 'rollover" with a mouseover. The second image is to be in the exact same place as the first. The images may be anywhere on the page at any given time depending on the coordinates.

Is this possible? ...any suggestions?
 
instead of dynamically positioning the image, enclose the image in a <div> and position the div. rollover should be the same as with a static image.

--Chessbot
 

No need for a DIV at all - simply give the image an ID, and change its source dynamically... So if your image had an ID of "myImage":

Code:
<img src="foo.gif" id="myImage" ... />

then this would change its source:

Code:
document.getElementById('myImage').src = 'bar.gif';

The JS code can be moved into a function which can easily be called on a mouseover event.

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top