Text Change upon Pic Click

V

voodoodan

Hi there!

I have the following code, which provides a clickable thumbnail
picture:

<li><a href="#nogo" class="hor"><img src="photo/pic_8h.jpg"
alt="" title="" /><b>Vivamus
nec metus et nunc auctor tristique.</b></a></li>

I'd like to have large text appear on the page, no less than two
words, which will describe the photo once it's clicked. The text
would then change upon another picture being clicked.

Does anyone know how this could be achieved using Javascript?!?

Thanks,
Dan.
 
E

Erwin Moller

voodoodan said:
Hi there!

I have the following code, which provides a clickable thumbnail
picture:

<li><a href="#nogo" class="hor"><img src="photo/pic_8h.jpg"
alt="" title="" /><b>Vivamus
nec metus et nunc auctor tristique.</b></a></li>

I'd like to have large text appear on the page, no less than two
words, which will describe the photo once it's clicked. The text
would then change upon another picture being clicked.

Does anyone know how this could be achieved using Javascript?!?

Hi,

Can be done in many ways.
The easiest is perhaps:
1) add a span or div to each picture, with an id.
2) add an onClick -handler to each picture, that replaces the text inside
the div or span. You can use something like this:
(I removed the useless a href)

<li>
<img src="photo/pic_8h.jpg"
onClick="document.getElementById('8h').innerHTML='Vivamus nec metus et nunc
auctor tristique.';">
<br>
<span id="8h"></span>
</li>

But you didn't describe where the short descriptions comes from.
A database?
Flat file?
Or do you type them yourself for each picture?

Regards,
Erwin Moller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top