.slice()
methodThe .slice()
method in jQuery is used to get a subset from the set of matched elements according to a range of indices.
.slice()
method Syntax.slice(star[,end])
.slice()
method ExampleAdd background color to the divs based on a slice
$( "li" ).slice( 1,3 ).css( "background-color", "cyan" ); // counting from the end of the set $( "li" ).slice( -2,-1 ).css( "background-color", "yellow" );