Advertisement
squarecat

jQuery Dimmer Switch

Sep 14th, 2011
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.91 KB | None | 0 0
  1. <p style="z-index:1;">Lorem ipsum...</p>
  2. <p style="z-index:3; position:relative;"><a id="dimmerSwitch" href="#"><span id="turnDown">Dim</span> the lights</a></p>
  3. <div id="inlineVideoBoxPlayer" style="z-index:3; position:relative;">...</div>
  4. <div id="dim" style="display:none; opacity: 0.5; position: fixed; width: 100%; height: 100%; z-index: 2; left: 0; top: 0; background-color: black;"></div>
  5. <script type="text/javascript">
  6.     $(function() {
  7.         $("#dimmerSwitch").toggle(
  8.             function() {
  9.                 $('#dim').fadeIn();
  10.                 $('#turnDown').replaceWith('<span id="turnUp">Raise</span>');
  11.                 $(this).css('color', 'white');
  12.             },
  13.             function() {
  14.                 $('#dim').fadeOut();
  15.                     $('#turnUp').replaceWith('<span id="turnDown">Dim</span>');
  16.                 $(this).css('color', '');
  17.             }
  18.         );
  19.     });
  20. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement