2009-11-28 25 views

回答

2

使用the less-than selector選擇所有索引小於8的索引(索引8是第九個列表項)。然後告訴他們:

$("#mylist li:lt(8)").show(); 

(假設你的清單 - olul - 具有mylistid;相應調整)

您可能需要做這兩個步驟,如果一些列表項初始是可見:

$("#mylist li") // select all list items 
    .hide() // hide them 
    .filter("li:lt(8)") // now select just the first eight 
    .show(); // ...and show them. 

(實際上,這是在殺除顯示一些項目,有些是隱藏的 - 如果你知道一個事實,即所有項目初始是可見的,你可以使用the greater-than selector簡單地隱藏與索引8和上述項 - as Corey demonstrates

3
$("li:lt(8)").show(); 

此選擇第一8個li元素。 :li選擇索引小於所選數字的元素。

2

$( 「李:LT(8)」)中:長線選擇與索引的所有li元素小於8

3
$('li:gt(7)').hide(); 

您可以使用7,因爲它是一個從零開始的索引。

相關問題