Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript jQuery only shows Image element once in IE. FF works
    text
    copied!<p>I want to show a big Image when I press the small thumbnail. A simple Lightbox style script.</p> <p>When I press the grey transparent overlay area around the image, the CSS and image is removed from view. This code is stripped down. Maybe missed something needed...</p> <pre><code>$(document).ready(function() { $(".lightBobo").click(function(e) { e.preventDefault(); // prevent to open link in new window $(this).lightBobo(); }); }); jQuery.fn.lightBobo = function(e) { if (e != undefined) e.preventDefault(); return this.each(function() { var img = new Image(); $(img).load(function() { imgW = img.width; imgH = img.height; var overlay = $("&lt;div /&gt;"); var container = $("&lt;div /&gt;"); // Lots of css styling for &lt;div&gt; overlay and container image... container.append(img); //add image to div $("body").append(overlay); //add overlay to body $("body").append(container); //add div to body overlay.fadeIn("fast", function() { container.show(); }); $(overlay).click(function() { removeDivs(); }); function removeDivs() { container.hide(); overlay.fadeOut("fast"); img = null; container = null; overlay = null; openImgSrc = ""; } }); }); } </code></pre> <p>The problem is IE(7) is not showing the image the second time I want to show it. I have to do a page reload to display the image again. It works in FF though.</p> <p>When I use FireFox I can see in FireBug that the get appended to for each time I show the big image. And the "old" image get's display: none; After 20 times I show the big image, I have 40 elements of Overlay and Container(image).</p> <p>I can't figure out how to rerun the lightBobo function when needed. So it workes in both IE and FF.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload