changing pictures...trouble...

Biggie_mac

OSNN Junior Addict
#1
I am having a problem with a "picture swap". I want to place a small picture which changes to another picture when you place the mouse over. i've tried the hover button from frontpage but it takes 5-6 sec until the buttons can be seen(there are 7 of'em). I've tried this:

<img src="poze/produse.jpg" height="21" width="160" border="1" name="picture2"
onmouseover ="document.picture2.src = 'poze/produse2.jpg' "
onmouseout ="document.picture2.src = 'poze/produse.jpg' "</a></a><p style="margin-top: 0; margin-bottom: 0" align="center">

but it either doesn't work or I have to hold the mouse over for 5-6 sec for the picture to change...who can give me some hints regarding this problem?
 
#2
heheh still the wrong forum :D you want coding and design but anyway :p

IIRC you need to specify its javascript somehow... but dontquote me on that.
 

albybum

Penguin Rancher
#4
Code:
<img src="poze/produse.jpg" border="1" id="picture2" 
onmouseover="document.getElementById('picture2').src='poze/produse2.jpg';" 
onmouseout="document.getElementById('picture2').src='poze/produse.jpg';" />

See it in action: http://www.albybum.net/temp/osnn/

Any lag time in the image rollover working could be due to the size of the image.
 

albybum

Penguin Rancher
#6
Teaching someone to use the fully qualified method, ie getElementByID(), will give them the ability to change other images and more importantly other elements outside the scope of the current element.

Using 'this' keyword is valid and very handy when you want to avoid ID attributes, but I like to make sure people get the detailed example. :)
 

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,970
Messages
673,297
Members
89,016
Latest member
Poseeut