jQuery Tutorial Tutorials - jQuery .slice() method

jQuery .slice() method

The .slice() method in jQuery is used to get a subset from the set of matched elements according to a range of indices.

jQuery .slice() method Syntax

.slice(star[,end])

jQuery .slice() method Example

example

Add 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" );

Try now

Date:2019-08-26 14:17:12 From:www.Lautturi.com author:Lautturi