Unread 09-05-2007, 05:25 AM
bcarl314 bcarl314 is offline
Senior Member
Join Date: Aug 2007
Posts: 141
  #1  
Default copy source_image src to another image from onclick

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...
Reply With Quote
Unread 11-15-2007, 10:24 AM
Mr J
Posts: n/a
  #2  
Default

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">
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 11:20 AM.


Powered by vBulletin® Version 3.0.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.