所以我有一個div自動設置爲在頁面加載時不顯示none。當點擊一個特定的鏈接時,它應該顯示爲fadeIn'slow',反之亦然。jQuery淡入淡出速度效果只能使用一次
fadeIn在http請求後第一次點擊它,但fadeOut沒有(但關閉)。 第一次完全淡入效果完全不起作用。那麼它的行爲就好像它是隱藏()和show()
代碼:
$('#req_login, #srch_login').click(function() {
$('#popbox, #popbox_bg').show(0); // opacity background
$('#popbox #container').fadeIn('slow'); // actual div with content
$("#email_alt_lgn").focus(); // first field in form
// close popbox with escape key
$(document).keyup(function(e) {
if (e.keyCode == 27) {
$('#popbox_close').click(); // trigger close link
}
});
});
$('#popbox_close').click(function() {
$('#popbox #container').fadeOut('slow'); // actual div with content
$('#popbox, #popbox_bg').hide(0); // opacity background
});
HTML:
// this is the part that should fadeIn() and fadeOut()
<div id="popbox" style="display: none;">
<div id="container">
<form method="POST" action="" name="login_form">
<span style="float: right;"><a id="popbox_close" class="button makeCircle" title="Sluiten of [Esc]">X</a></span>
(... form content omitted)
</form>
</div>
</div>
<div id="popbox_bg" style="display: none;"></div>
// this is what should trigger the fadeIn() event
<a id="req_login">Inloggen</a><span class="pin_split_white"></span>
你可以無憂嗎? – moettinger 2012-08-14 18:31:38
具有實際的html也有助於 – moettinger 2012-08-14 18:32:14