<script type="text/javascript">
$(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();
});
});
</script>
</head><body>
<div id="subNav">
<div id="status">
<a href="#loginPanel" rel="popup">Login</a>
<div id="loginPanel" class="window">
<a class="close" href="#close"></a>
Login Form
</div>
<a href="#registerPanel" rel="popup">Register</a>
<div id="registerPanel" class="window">
<a class="close" href=""></a>
Register Form
</div>
</div>
</div>
script above i put at header.php,
but nothing happend when i click the a tag from url/index.php(require header.php)
but work excellent when i surf url/header.php , how come?
i put the script in head
firefox Error console:
Error: $(“a[rel=popup]”) is null
Source File: http://localhost/
You probably did something like that
You should put header in body section!