Easy Tutorial
❮ Misc Isfunction Event Holdready ❯

jQuery slice() Method

jQuery Traversing Methods

Example

Selects <p> elements starting from the one with index number 2:


Definition and Usage

The slice() method selects a subset of elements based on their index.

A subset is a collection that is part of a larger collection.

This method is used to limit the selection of elements in a set by specifying a start and an optional end point: The start parameter is the starting index (starting from 0) to create the subset, and the stop parameter is an optional end point.


Syntax

Parameter Description
start Required. Specifies the starting position to select elements. The index starts at 0. <br> <br> Note: If negative, it indicates starting from the end of the selected elements, rather than the beginning.
stop Optional. Specifies the ending position to select elements. If omitted, the selection extends to the end of the set. The index starts at 0. <br> <br> Note: If negative, it indicates starting from the end of the selected elements, rather than the beginning.

More Examples

start and stop

Using negative numbers

Using negative numbers with two parameters


jQuery Traversing Methods

❮ Misc Isfunction Event Holdready ❯