2011-01-11 11 views
2

誰かが私を助けてくれる?残りのjQueryが要素のリストを構築する前に、.jshowoff-link要素を隠す必要があります。私は最後に同じ要素を表示します。jQuery .show();関数は以前隠されたすべての要素を表示していません

リンク内の画像のリストを生成します。何らかの理由で、最初の画像とリンクのみを表示し、他の画像やリンクは表示しません。

私は.show();関数の位置をスワップし、最後のif elseステートメントの内側に追加しようとしましたが、どちらも機能しません。

.jshowoff();ファンクショントリガーの前に表示される画像とリンクのリストを停止するためにこれがすべて実行されます。

私はすべてのアイデアがありません。誰でも助けることができますか?

// hide banners to begin with 
$ ('.jshowoff-link').hide(); 

// this function wraps the elements in the neccessary tags to work with anything Slider 
$ (document).ready(function() { 
    $('a.jshowoff-link') 
     .wrap('<li class="jshowoff-slide"></li>'); 
    $('li.jshowoff-slide') 
     .wrapAll('<ul id="jshowoff"></ul>'); 
    // figures out if there's more than one <li> being produced 
    if (banners.length > 1) { 
     // if so, build the jshowoff 
     $('#jshowoff').jshowoff({speed:7000, changeSpeed:1000, autoPlay:true, controls:true, links:true, animatePause:false, hoverPause:false }); 
     } 
    else { 
     // if not, disable the function 
     $('#jshowoff').jshowoff({speed:7000, changeSpeed:1000, autoPlay:false, controls:false, links:false, animatePause:false, hoverPause:false }); 
     } 
    // show the jshowoff after it's been built to stop flash of content on slow internet connections 
    $('.jshowoff-link').show(); 
    return false; 
    }); 
+0

私は[ 'ライブ()'](HTTPを使用してお勧めしたいです。 com/live /)が、どのイベントタイプを使用できるかはわかりません。 –

答えて

1

問題はこれです:jshowoffが起動したとき、それは#jshowoffコンテナからすべての子要素を削除し、変数に入れます。その後、それらをコンテナに1つずつ追加します。このため、あなたのリンクはshow()にしようとすると、DOMにはありません。

$ (document).ready(function() { 
    $('a.jshowoff-link') 
     .wrap('<li class="jshowoff-slide"></li>'); 
    $('li.jshowoff-slide') 
     .wrapAll('<ul id="jshowoff"></ul>'); 

    var $container = $('#jshowoff'); 

    $container.hide(); 

    // figures out if there's more than one <li> being produced 
    if (banners.length > 1) { 
     // if so, build the jshowoff 
     $container.jshowoff({speed:7000, changeSpeed:1000, autoPlay:true, controls:true, links:true, animatePause:false, hoverPause:false }); 
     } 
    else { 
     // if not, disable the function 
     $container.jshowoff({speed:7000, changeSpeed:1000, autoPlay:false, controls:false, links:false, animatePause:false, hoverPause:false }); 
     } 
    // show the jshowoff after it's been built to stop flash of content on slow internet connections 
    $container.show(); 

    return false; 
}); 

それでも要素を点滅取得する場合、あなたは、コンテナを作成し、最初のリンクを隠すことができます:あなたは何ができるか、通話が終了した後、再びそれを示し、その後、jshowoff()を呼び出す前に、完全なjshowoff要素を非表示にしています、それを隠し、再びリンクを示しており、このように、その後、jshowoffを追加し、再びコンテナを示しています。//api.jquery:

// hide banners to begin with 
$ ('.jshowoff-link').hide(); 

$ (document).ready(function() { 
    $('a.jshowoff-link') 
     .wrap('<li class="jshowoff-slide"></li>'); 
    $('li.jshowoff-slide') 
     .wrapAll('<ul id="jshowoff"></ul>'); 

    var $container = $('#jshowoff'); 

    $container.hide(); 

    // The links are still attached to the DOM at this point, but hidden inside the hidden container. 
    $('.jshowoff-link').show(); 

    // figures out if there's more than one <li> being produced 
    if (banners.length > 1) { 
     // if so, build the jshowoff 
     $container.jshowoff({speed:7000, changeSpeed:1000, autoPlay:true, controls:true, links:true, animatePause:false, hoverPause:false }); 
     } 
    else { 
     // if not, disable the function 
     $container.jshowoff({speed:7000, changeSpeed:1000, autoPlay:false, controls:false, links:false, animatePause:false, hoverPause:false }); 
     } 
    // show the jshowoff after it's been built to stop flash of content on slow internet connections 
    $container.show(); 

    return false; 
}); 
+0

2番目のソリューションは完全に機能しました。とても有難い。 –

関連する問題