Hello,
I ran across a very simple Javascript image swap solution that works nearly perfectly for my needs and is easy to implement. If possible I would like to edit this script or add another function to it that would pull text (perhaps from the title attribute) and display it as a caption underneath.
Here is the javascript:
function swapImage(elem)
{
if (!document.getElementById) return false;
var bigPic = elem.getAttribute('href');
document.getElementById('mainpic').setAttribute('src', bigPic);
}
The <a> tag needs to have this as an attribute: onclick="swapImage(this);return false;"
The image that is to be replaced should have an id that matches the script. In this case id="mainpic"
Can anyone help me pull text out of the html and display it along with the image that is being swapped? Calling me a javascript noob would be an understatement.
If you need more info from me, just let me know. Thank you!
I ran across a very simple Javascript image swap solution that works nearly perfectly for my needs and is easy to implement. If possible I would like to edit this script or add another function to it that would pull text (perhaps from the title attribute) and display it as a caption underneath.
Here is the javascript:
function swapImage(elem)
{
if (!document.getElementById) return false;
var bigPic = elem.getAttribute('href');
document.getElementById('mainpic').setAttribute('src', bigPic);
}
The <a> tag needs to have this as an attribute: onclick="swapImage(this);return false;"
The image that is to be replaced should have an id that matches the script. In this case id="mainpic"
Can anyone help me pull text out of the html and display it along with the image that is being swapped? Calling me a javascript noob would be an understatement.
If you need more info from me, just let me know. Thank you!