Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Little Help with some jQuery Overlay

Posted on 2010-11-18
Medium Priority
Last Modified: 2012-05-10
Been banging my head on this problem for a little while and it's getting late hopefully someone will see what is wrong with the code.  I am using jQuery to have a vertical scroll box of images which fill a div to the left of it on mouseover.  All of this part of the code works fine.  I am trying to implement a lightbox type effect using the jQuery function overlay.  This seems to work great so long as I do not use javascript to switch which file is loaded.  If I use the javascript I currently have to switch the images, the images themselves do appear however the close button never appears in the upper right corner as it should.  I have tried a few different things to no affect.
The image code which works currently can be found on line 129.  What I want is to comment that out and use the js function "setImage" (currently set to "ssetImage" to allow the working code to run properly on line 147.
Hope someone can tell me what I am doing wrong here...  Thanks in advance!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
        <title>Image Scroller</title>
        <script type="text/javascript" src=""></script>
        <script type="text/javascript" src="thumbnailviewer.js"></script>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="style.css">
            /* the overlayed element */
            .simple_overlay {

                /* must be initially hidden */

                /* place overlay on top of other elements */

                /* styling */

                border:1px solid #666;

                /* CSS3 styling for latest browsers */
                -moz-box-shadow:0 0 90px 5px #000;
                -webkit-box-shadow: 0 0 90px #000;

            /* close button positioned on upper right corner */
            .simple_overlay .close {
            /* styling for elements inside overlay */
            .details {

            .details h3 {
                margin:0 0 -10px 0;
        <div id="container">
            <div id="actions">
                <a class="prev">&laquo; Back</a>
                <a class="next">More pictures &raquo;</a>
            <div id="loadarea" style="margin:0 auto;">

            <!-- root element for scrollable -->
            <div class="scrollable vertical">
                <!-- root element for the items -->
                <div class="items">
                    <!-- Page 1 -->
                        <!-- Item 1 -->
                        <div class="item">
                            <a href="/fma/img/1.jpg" rel="enlargeimage" rev="targetdiv:loadarea,trigger:mouseover,preload:yes,fx:fade">
                                <img class="thumbnail" src="img/1.jpg" rel=".simple_overlay" alt="Image 1" onclick="setImage(1)">
                            <h3>Image Title 1</h3>
                        <!-- Item 2 -->
                        <div class="item">
                            <a href="/fma/img/2.jpg" rel="enlargeimage" rev="targetdiv:loadarea,trigger:mouseover,preload:yes,fx:fade">
                                <img class="thumbnail" src="img/2.jpg" rel=".simple_overlay" alt="Image 2" onclick="setImage(2)">
                            <h3>Image Title 2</h3>
                        <!-- Item 3 -->
                        <div class="item">
                            <a href="/fma/img/3.jpg" rel="enlargeimage" rev="targetdiv:loadarea,trigger:mouseover,preload:yes,fx:fade">
                                <img class="thumbnail" src="img/3.jpg" rel=".simple_overlay" alt="Image 3" onclick="setImage(3)">
                            <h3>Image Title 3</h3>
                    </div> <!-- End of Page 1 -->
                    <div><!-- Page 2 Starts here -->
                        <!-- Page 2 -->
                            <!-- Item 4 -->
                            <div class="item">
                                <a href="/fma/img/4.jpg" rel="enlargeimage" rev="targetdiv:loadarea,trigger:mouseover,preload:yes,fx:fade">
                                    <img class="thumbnail" src="img/4.jpg" rel=".simple_overlay" alt="Image 4" onclick="setImage(4)">
                                <h3>Image Title 4</h3>
                            <!-- Item 5 -->
                            <div class="item">
                                <a href="/fma/img/5.jpg" rel="enlargeimage" rev="targetdiv:loadarea,trigger:mouseover,preload:yes,fx:fade">
                                    <img class="thumbnail" src="img/5.jpg" rel=".simple_overlay" alt="Image 5" onclick="setImage(5)">
                                <h3>Image Title 5</h3>
                            <!-- Item 6 -->
                            <div class="item">
                                <a href="/fma/img/6.jpg" rel="enlargeimage" rev="targetdiv:loadarea,trigger:mouseover,preload:yes,fx:fade">
                                    <img class="thumbnail" src="img/6.jpg" rel=".simple_overlay" alt="Image 6" onclick="setImage(6)">
                                <h3>Image Title 6</h3>
                        </div> <!-- End of Page 2 -->

        <!-- first overlay. id attribute matches our selector -->
        <div class="simple_overlay" id="overlayInsert">

            <!-- large image -->
            <img src="/fma/img/1.jpg" />

            <!-- image details 
            <div class="details">
                <h4>Sub Title</h4>
                <p>The content ...</p>

        <script type="text/javascript">
            // execute your scripts when DOM is ready. this is a good habit
            jQuery(document).ready(function() {
                //set the overlay for imgs with rel matching id/class
                // initialize scrollable with mousewheel support
                jQuery(".scrollable").scrollable({ vertical: true, mousewheel: true });
            function ssetImage(img){
                imgOverlay = document.getElementById("overlayInsert");
                imgOverlay.innerHTML = ("<img src=\"img/"+img+".jpg\">");

Open in new window

Question by:PhillipsPlastics
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Expert Comment

ID: 34170668
can you post an example url?

Accepted Solution

PhillipsPlastics earned 0 total points
ID: 34172264
Here's it working with a single image for the overlay:
Working Model

Here's it working with multiple images but without a close button:

Author Comment

ID: 34179818
Solved my problem.

Author Closing Comment

ID: 34211291

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question