The slice method in jQuery
Using the slice method, you can access a portion of the elements of a set, for example, from the second to the fifth.
Let's look at how the method works using the following example - let's say we have the following HTML code:
<p>text0</p>
<p>text1</p>
<p>text2</p>
<p>text3</p>
<p>text4</p>
<p>text5</p>
Now, for paragraphs from 2-th to 4-th (inclusive), we will add the text '!' at the end (numbering from zero, the second paragraph will have the number one):
$('p').slice(1, 5).append('!');
HTML the code will look like this:
<p>text0</p>
<p>text1!</p>
<p>text2!</p>
<p>text3!</p>
<p>text4!</p>
<p>text5</p>
Note that slice(1, 5) includes the first argument but not the second, so (1, 5) finds elements with numbers 1, 2, 3, 4, but does not take elements with numbers 0 and 5.
Find the 3th through 10th lith in the set and color them red.