0

現在の状況: 4 つのナビゲーション リンクをクリックすると、コンテンツ フィールドがアニメーションで開きます。

問題: 一度に 1 つのコンテンツ フィールドを開く必要があるときに、すべてのコンテンツ フィールドを開くことができます。

解決策: ナビゲーション リンクをクリックするときは、すべてのコンテンツ フィールドを閉じて、1 つだけ開きます。

This is the script which works, (the overlay is useless):

JSFiddleはこちら

4

1 に答える 1

0
$(function() {
    $('.activator').each(function(){
        $(this).click(function(){
            showHideAnimation(clickedObj);
        });
    });
}

function showHideAnimation(clickedObj)
{
    $('.activator').each(function(){
        if($(this).id == clickedObj.id) {
            $(this).fadeIn('fast',function(){
                $(this).animate({'bottom':'0px'},800);
            });
        } else {
            $(this).animate({'bottom':'-600px'},800,function(){
                $(this).fadeOut('fast');
            });
        }
    }
}

正しく動作しない場合はこれを試してから、$(this)をこれだけに置き換えてください

于 2013-01-20T11:17:21.480 に答える