943,175 Members | Top Members by Rank

Ad:
Aug 30th, 2010
0

jQuery: Div is not showing when clicked

Expand Post »
Hi,
I have a hidden DIV, which is going to cover all of the screen as part of a lightbox. I wrote my code based on what I found at docs.jquery.com/Tutorials:Basic_Show_and_Hid . When I click on the link to run the lightbox, the div isn't showing even through the z-index is the highest on the page. I've also tried seeing if it was a corrupted version of jQuery. What's wrong?

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <style type="text/css">
  2. #video1
  3. {
  4. position:absolute;
  5. top:350px;
  6. left:0px;
  7. width:100px;
  8. height:100px;
  9. background-color:#00FF00;
  10. z-index:4;
  11. }
  12.  
  13. #lightbox
  14. {
  15. position:absolute;
  16. top:0%;
  17. left:0%;
  18. height:100%;
  19. width:100%;
  20. background-color:#000000;
  21. opacity:0.7;
  22. visibility:hidden;
  23. z-index:5;
  24. }
  25. </style>
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script>
  2. <script type="text/javascript">
  3. $(document).ready(function(){
  4. $("#video1").click(function(){
  5. $("#lightbox").show();
  6. alert("test");
  7. });
  8. });
  9. </script>
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Index</title>
  6. </head>
  7. <body>
  8. <div id="video1"></div>
  9. </body>
  10. </html>
Last edited by bsewell; Aug 30th, 2010 at 1:28 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
bsewell is offline Offline
53 posts
since Sep 2009
Aug 30th, 2010
0
Re: jQuery: Div is not showing when clicked
jQuery's show function doesn't work with the visibility attribute. It works with the display attribute.

Change your JS code to say $("#lightbox").css("visibility", "visible") instead of $("#lightbox").show().
Reputation Points: 15
Solved Threads: 6
Newbie Poster
pwinfrey is offline Offline
18 posts
since Jul 2010
Aug 31st, 2010
0
Re: jQuery: Div is not showing when clicked
Hi,
thanks for the reply. The code works perfectly now, I needed to add a div tag for lightbox in the XHTML as well as the change needed.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
bsewell is offline Offline
53 posts
since Sep 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Javascript Query Parser
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Javascript to php?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC