Jump to content

[SOLVED] How to load pictures instantly?


jpmad4it

Recommended Posts

hey everyone,

 

I want to find out if its possible to load an image dynamically on the click of a button, within the same webpage. For example I want to have a thumbnail which has a link to a larger image, which will be loaded without having to open up a pop-up or separate page. I'd have 4 or 5 thumbnails at the top of the page, and then a larger area below that where the larger image is loaded on the click of the thumbnail. Is this possible? How could it be done? I know this is probably a relatively easy question, so sorry for being a newbie LOL  ;D

 

regards Jp

Link to comment
Share on other sites

create your larger image tag like this:

<img src="start image url" id="largepic"> 

code each of your thumbnail pics like this:

<a href="#" onclick="document.getElementById('largepic').src='new pic url';return false;"><img src="one thumbnail url"></a>

--notice the onclick event coded into the link code.  It getElementById's the id of the large image and then replaces the src attribute of that image with the new large picture url.  Just code the link for each thumbnail the same except use a different 'new pic url'.  Pay close attention to the use of single quotes and double quotes in the onclick=.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.