Jessi
Jessi

Reputation: 1

change my main image when a button is clicked

C:\Documents and Settings\Omar.Abulawi\Desktop\t3\main.htm This is a site i'm working on, now i'm trying to change and replace the main image with different ones according to one of the five menus once they are clicked. But with no use! Your help and advice would be appreciated :)

Upvotes: 0

Views: 39

Answers (2)

Danield
Danield

Reputation: 125493

You can actually do this with pure css using The :target pseudo class.

FIDDLE

Note: You'll need a modern browser to use this method. (IE9+)

Also, take a look at this article which shows some clever ways to simulate click events with css (one of them being the :target pseudo class.

Upvotes: 1

imulsion
imulsion

Reputation: 9040

Well, based on what you've said, this JavaScript should do it:

function changeimage()
{
    document.getElementById("picture_id").src = "new_file_path";
}

Call that function in the onclick events of your menus.

Upvotes: 1

Related Questions