2012-02-28 134 views
0

我有我的主頁滑塊與我的標記作爲如此...淡出元素= X

 <li id="fragment-3" class="slides virtualsation ui-tabs-panel ui-tabs-hide" style="display: list-item;"> 
       <h1>Virtualisation</h1> 
       <p>By implementing virtualisation into Council managed to save them over £250,000 in annual expenditure.</p> 
       <div class="animation"> 
        <div class="big-server"><img src="_includes/images/sliders/big-server.png"></div> 
        <div class="arrow"><img src="_includes/images/sliders/arrow.png"></div> 
        <div class="small-server-one"><img title="Title Text Blah" src="_includes/images/sliders/small-server.png"></div> 
        <div class="small-server-two"><img title="Title Text Blah" src="_includes/images/sliders/small-server.png"></div> 
        <div class="small-desktop"><img title="Title Text Blah" src="_includes/images/sliders/small-desktop.png"></div> 
       </div> 
     </li> 

我想在我的動畫元素每個孩子淡入當父裏有內聯風格的顯示:list-item;

這可能與jQuery?

我雖然關於使用.closest(),但wwasnt確保標識針對如何使用內嵌的風格股利...

+0

這是由jQueryUI選項卡小部件驅動?如果很容易綁定到標籤事件 – charlietfl 2012-02-28 16:54:10

回答

1

如果您向我們展示何時以及如何將顯示更改爲列表項,它會使它更容易。

您可以查看jQuery的函數$ .Deffered,並將其附加到更改li元素顯示的方法。這樣你可以稍後創建一個監聽的函數,而不是將顯示設置爲list-item。

或者你可以定義裏顯示,像這樣的方法中製作動畫:

既然是一個滑塊,我認爲它改變了當按下箭頭,並且列表項你已經展現我們,是其中一個滑塊。

// when you click next 
$('.arrow-next').on('click', function(){ 

    // hides the current, sets the next to list-item and caches the 'next' li 
    var nextLi = $('li.current').css('display','hidden').next('li').css('display','list-item') 

    // fades in every element in the div.animation that is within the 'next' li element 
    $('div.animation *', nextLi).fadeIn() 


}) 

希望這可以幫助你。如果上面的例子沒有解決你的問題,那麼我不太清楚你是如何處理從不是列表項到列表項的轉換。無論如何,希望它有幫助。

0

如果我理解正確的話,像這樣的工作:

var hasInlineListItem = $('#whatever').closest('li').is(function() { 
    return this.style.display == 'list-item'; 
}); 

if (hasInlineListItem) { 
    //do whatever you want 
} 

jsFiddle Demo to illustrate how it works

jQuery有幾個你可以使用的filter methods。我在這裏使用了is(),這將返回一個布爾值。