jQueryslice ()メソッド
例
インデックス番号2の<p>要素から<p>要素の選択を開始します。
$("p").slice(2)
定義と使用法
lice()メソッドは、そのインデックスに基づいて要素のサブセットを選択します。
サブセットは、より大きなセットの一部であるセットです。
このメソッドは、開始点と終了点によってグループ内の要素の選択を制限するために使用されます。開始パラメーターはサブセットを作成する開始インデックス(0から開始)であり、停止パラメーターはオプションの終了点です。
構文
$(selector).slice(start,stop)
Parameter | Description |
---|---|
start | Required. Specifies where to start the selection of elements. The index numbers start at 0. Note: Using a negative number will select elements from the end of the selected elements, instead of the beginning. |
stop | Optional. Specifies where to end the selection of elements. If omitted, the selection continues until the end of the set. The index numbers start at 0. Note: Using a negative number will select elements from the end of the selected elements, instead of the beginning. |
自分で試してみてください-例
両方のパラメーターを使用して、開始点と終了点から<p>要素を選択する方法。
を使用する負の数を使用して、最初ではなく最後から数えて<p>要素の選択を開始します。
使用する負の数で開始および停止を使用して、最後から数えて<p>要素の選択を開始します。