need some help . about jquery
<pre><code>            &lt;script type="text/javascript"&gt;
        $(document).ready(function() {  

            //select all the a tag with name equal to modal
            $('a[rel=popup]').click(function(e) {
                //Cancel the link behavior
                e.preventDefault();

                //Get the A tag
                var id = $(this).attr('href');

                //Get the screen height and width
                var maskHeight = $(document).height();
                var maskWidth = $(window).width();

                //Set heigth and width to mask to fill up the whole screen
                $('#mask').css({'width':maskWidth,'height':maskHeight});

                //transition effect     
                $('#mask').fadeTo("slow",0);    

                //Get the window height and width
                var winH = $(window).height();
                var winW = $(window).width();

                //Set the popup window to center
            $(id).css('top', $(this).height() + $(this).offset().top + 5);

                //transition effect
                $(id).fadeIn(1000); 

            });

            //if close button is clicked
            $('.window .close').click(function (e) {
                //Cancel the link behavior
                e.preventDefault();

                $('#mask').hide();
                $('.window').hide();
            });     

            //if mask is clicked
            $('#mask').click(function () {
                $(this).hide();
                $('.window').hide();
            });         

        });
            &lt;/script&gt;
&lt;/head&gt;&lt;body&gt;
      &lt;div id="subNav"&gt;
        &lt;div id="status"&gt;

            &lt;a href="#loginPanel" rel="popup"&gt;Login&lt;/a&gt;
            &lt;div id="loginPanel" class="window"&gt;
              &lt;a class="close" href="#close"&gt;&lt;/a&gt;
              Login Form
            &lt;/div&gt; 

            &lt;a href="#registerPanel" rel="popup"&gt;Register&lt;/a&gt;
            &lt;div id="registerPanel" class="window"&gt;
            &lt;a class="close" href=""&gt;&lt;/a&gt;
              Register Form
            &lt;/div&gt;

        &lt;/div&gt;
      &lt;/div&gt;
</code></pre>

<p>script above i put at header.php,</p>

<p>but nothing happend when i click the a tag from url/index.php(require header.php)</p>

<p>but work excellent when i surf url/header.php , how come?</p>

<p>i put the script in head </p>

<p>firefox Error console:</p>

<p>Error: $("a[rel=popup]") is null</p>

<p>Source File: <a href="http://localhost/" rel="nofollow">http://localhost/</a></p>
