Javascript examples for jQuery Method and Property:slice
slice from the end using negative values
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").slice(-3, -1).css("color", "red"); });/* w ww . j a v a 2s. c o m*/ </script> </head> <body> <p>this is a test (index 0).</p> <p>this is a test (index 1).</p> <p>this is a test (index 2).</p> <p>this is a test (index 3).</p> <p>this is a test (index 4).</p> </body> </html>