jQuery slice() by start and end

Description

jQuery slice() by start and end

View in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p").slice(1,3).css("background-color", "yellow");
});//www . ja v  a  2 s. co m
</script>
</head>
<body>

<h1>Welcome to My Homepage</h1>

<p>This is a test (index 0).</p>
<p>CSS (index 1).</p>
<p>I am from java2s.com (index 2).</p>
<p>This is another test (index 3).</p>
</body>
</html>



PreviousNext

Related