Hello, i need javascript for html page, it should work like that - there are thumbnails, and if i mouseover them, changes the image and text. can anyone help me?
Javascript txt and image swap
Started by aega, Dec 03 2008 11:07 AM
3 replies to this topic
#1
Posted 03 December 2008 - 11:07 AM
#2
Posted 03 December 2008 - 06:32 PM
#3
Posted 04 December 2008 - 06:30 AM
i found ideal solution, but how to do that on html page? http://dasme.org/imagegal/demo/#
Edited by aega, 04 December 2008 - 12:22 PM.
#4
Posted 04 December 2008 - 08:47 PM
I don't have time to explain too in-depth, but i will explain the general process for you so you can figure it out on your own.
So... you have an html image tag that holds the image (i.e. <img src="someimage.jpg" id="img_container" />), give it an id, say "img_container", then you've got a text link, or a thumbnail link, and on this link, you'll use the onclick option of the html <a href> tag. In the onclick, you'll call a javascript function, which i will try to explain.
Let's say this function is called swap.
so you'd have.... <a href="someurl" onclick="swap(img_container,'path/to/new/image.jpg'); return false">
and your swap function will look a little something like this:
Good luck.
So... you have an html image tag that holds the image (i.e. <img src="someimage.jpg" id="img_container" />), give it an id, say "img_container", then you've got a text link, or a thumbnail link, and on this link, you'll use the onclick option of the html <a href> tag. In the onclick, you'll call a javascript function, which i will try to explain.
Let's say this function is called swap.
so you'd have.... <a href="someurl" onclick="swap(img_container,'path/to/new/image.jpg'); return false">
and your swap function will look a little something like this:
function swap(element, path){
//get element by id
//then do element.src = path
//now you've got the basics.
}
}
Good luck.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
