Go Back   Ultimate Web Site Drop Down Menu Forum > Web Development > Javascript
Register FAQ Members List Calendar Today's Posts

Reply
Thread Tools Display Modes
Unread 09-05-2007, 06: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, 11: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



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 05:14 PM.


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