Jump to content

Image popup on hover


KingOfHeart

Recommended Posts

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?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.