The slice() is an inbuilt method in jQuery which is used to select a subset of elements based on its index. The subset is a set that may be a part of a large set.
Parameter: It accepts two parameters which are specified below-
- para1: It specifies that where to start the selection of the elements.
- para2: It is optional and it specifies where to stop the selection of the elements.
Return Value: It returns the subset of the selected element.
jQuery code to show the working of slice() method:
In this code, all paragraph element from index 1 to 3 get highlighted.