Fade out entire page, except one jquery created div
Hi,
I am trying to work out how to fade out all of a page except for one div (that is dynamically created within the page). The problem I think is that the div that I want to remain highlighted is contained within the div that I want to fade.
Here is some sample, simplified code to demonstrate what I want to do:
- <html>
- <head>
- <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
- </head>
- <script type="text/javascript">
- $(document).ready(function(){
- $('a.fading').click(function() {
- $('#page').fadeTo(400, .2);
- $(this).append('<div class="highlighted">not faded out</div>');
- $('.highlighted').fadeTo(100, 1);
- });
- });
- </script>
- <body>
- <div id='page'>
- <p>This is the text that should be faded out</p>
- <a class='fading'>Click me</a>
- </div>
- </body>
- </html>
In the actual code, the html/jquery is generated by PHP and I do not have the option to have this div outside of the one I want to fade due to the architecture of the code.
How can I achieve the newly created div being 100% opacity, while everything else goes to 20%?
Thanks,
Ben