View Full Version : copy source_image src to another image from onclick
bcarl314
09-05-2007, 05:25 AM
Hi Forum, Im having trouble with my js. I have a series of img tags. each one needs to run a function with the onclick event. In the function I want to copy the src of the image into the src of a main -larger- img tag. I tried something like this: function doit(){ var node = this; var...
Try this
<script type="text/javascript">
function doIt(obj){
document.getElementById("bigpic").src=obj.src
}
</script>
<img src="pic1.jpg" width="100px" height="100px" onclick="doIt(this)">
<img src="pic2.jpg" width="100px" height="100px" onclick="doIt(this)">
<img src="pic3.jpg" width="100px" height="100px" onclick="doIt(this)">
<img src="pic4.jpg" width="100px" height="100px" onclick="doIt(this)">
<img id="bigpic" src="blank.jpg">
vBulletin® v3.0.1, Copyright ©2000-2024, Jelsoft Enterprises Ltd.