簡體   English   中英

Div未能正確顯示

[英]Div not displaying correctly on show

<script type='text/javascript'>
$(document).ready(function () {
    var fenster = $(location).attr('href');

    if (fenster == 'http://www.cyrill-kuhlmann.de/index.php/') {
        $('#intro-page').show(function () {
            $(this).click(function () {
                $(this).fadeOut(250);
            });
        });
    }
});
</script>

我有一個div ,需要以全屏顯示作為介紹。 問題在於它無法正確顯示; 它只是顯示在左上角,並一直增長到全屏。 為什么這樣做呢?

show()將動畫的持續時間作為第一個參數。 您給它提供了一個功能,這是不正確的。 您要么要鏈接您的方法:

$('#intro-page').show().click(function () {
    $(this).fadeOut(250);
});

或者,您的確打算在其中放置一個回調函數,但是您錯過了第一個參數; 持續時間:

$('#intro-page').show(250, function(){
    $(this).click(function(){
        $(this).fadeOut(250);
    });
});

文獻資料

<script type='text/javascript'>
$(document).ready(function () {
    var fenster = $(location).attr('href');

    if (fenster == 'http://www.cyrill-kuhlmann.de/index.php/') {
        $('#intro-page').show(function () {
            $(this).click(function () {
                $(this).fadeOut(250);
            });
        });
    }
});
</script>

嘗試以下方法:

<script type='text/javascript'>
$(document).ready(function () {
    var fenster = $(location).attr('href');

    if (fenster == 'http://www.cyrill-kuhlmann.de/index.php/') {
        $('#intro-page').show();
        $('#intro-page').click(function(){
           // seperate it from show function call so you can have more access to object
           // and do logic on it.
           $(this).fadeOut(250);
        });
    }
});
</script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM