Jump to content

Image popup on hover


KingOfHeart

Recommended Posts

I need a simple script to have an image be displayed on the page.

When I hover my mouse on image1, I need it to display it again on the screen. My image will only be 25% in size, so that's why I want a second image to show up.

 

Javascript or Css, it doesn't matter to me.

Link to comment
Share on other sites

Displaying the image is no problem, it's positioning it. As ohdang888 said there'll be plenty of jQuery (or other framework) plug-ins available, but I shouldn't think something so simple would really need a bloated plug-in.

 

Can you give more information on how you want the pop-up positioned? Plus, are you using a framework or just standard JavaScript?

Link to comment
Share on other sites

Using jQuery this would be a simple task. A VERY simple example, not tested.

 

<html>
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
    <script>
      $('#thumbs ul li').hover(
        function() {
          img = $(this).find('img').attr('src').replace('-thumb', '-full');
          $('#stage').html('<img src="' + img + '" />');
        },
        function() {
          $('#stage').html('');
        }
      );
    </script>
  </head>
  <body>
    <div id="thumbs">
      <ul>
        <li><img src="image1-thumb.jpg" /></li>
        <li><img src="image2-thumb.jpg" /></li>
        <li><img src="image3-thumb.jpg" /></li>
      </ul>
    </div>
    <div id="stage"></div>
  </body>
</html>

 

You'll need the images image1-thumb.jpg , image1-full.jpg etc etc

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.