0

Friends

light box not working in Chrome and IE but working for Mozilla. Its a coding problem I think,pls help me with a solution. I have given the code below.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> function check(chkbox,srr) { if (chkbox.checked) { var sre = $('srr'); $(function() { var lightboxHTML = '<div id="overlay"></div>' + '<div id="lightbox">' + '<a href="#" id="exit" onclick = "close2()">Close</a>' + '<img src='+sre+'/>' + '<p/>' + '</div>'; $(lightboxHTML).appendTo('body').hide(); $('#overlay').css('opacity', '0.8'); //$('img', '#lightbox').attr('src', sre); $('#overlay, #lightbox').show(); event.preventDefault(); }); } } </script> <script type="text/javascript"> function close2() { $(function() { $('#lightbox, #overlay').hide(); event.preventDefault(); }); } </script> 
2
  • If either you or a mod could format the Javascript with "code" tags, it would really help... Commented Jul 8, 2011 at 6:44
  • '<img src='+sre+'/>' + '<p/>' + '</div>'; why not 'srr' itself? instead of $ing it to 'sre' Commented Jul 8, 2011 at 8:06

2 Answers 2

0

It appears that $('srr') should either be $('#srr') or $('.srr'), as I am guessing srr is not a tag name. I'm not sure if this is the only problem.

Sign up to request clarification or add additional context in comments.

Comments

0

You probably need to show us how you're using this code.
You're sending in a variable called srr, but you're surrounding it with single quotes in your jquery selector.

Your second mistake is trying to use a jquery object as a string for the image source. I don't know what you're expecting your sre variable to be, but if you're selecting an image, then you should change your image tag to: <img src=' + sre.attr("src") + ' />

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.