PDA

View Full Version : onClick


jarbig
07-11-03, 04:19 PM
I am sorry to waste someone's time, but I am new to javascript. How would I go about changing an image and playing a sound in an onClick function?

Any input is greatly appreciated.

dwoody
07-29-04, 10:38 PM
With just a little research im sure you could figure out what you need. If you wanted to change an image you could do it easily like such:

<img src="whatever.jpg" name="theimage">
onClick="window.document.theimage.src='newimagesrc.jpg'"

just put the filename of the new image and the old image will change to that.
As far as playing a sound im not sure how u would do so without opening a media player of some sort which the person may not have.
I'm not sure this is what you were looking for but if so it should help.