<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>
сценарий выше я поставил в header.php,нужна помощь. о JQuery
, но ничего не случилось, когда я нажимаю тег из URL/index.php (требуется header.php)
но работают отлично, когда я surf url/header.php, как получилось?
я положил сценарий в голове
светлячок консоли Ошибка:
Ошибка: $ ("а [отн = всплывающее окно]") является нулевым
Источник файла: http://localhost/
небрежно первое, что я вижу, это head, который не закрыт ... но помимо этого ... вам нужно будет дать больше контекста и быть более конкретным, чем «он (не) work " –
Ваш образец кода не работает. Тег неправильно закрыт, и у вас нет тега
. У вас есть эти файлы в файлах PHP и не вставляете их здесь? – calvinfЯ получил тег тела на моем index.php, забыл скопировать и тег также без ошибок. firefox error console: Ошибка: $ ("a [rel = popup]") is null – user259752