Select element after p element - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:nextAll

Description

Select element after p element

Demo Code

ResultView the demo in separate window

<!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").nextAll().css("background-color", "blue");
});//from w ww  .j  av a  2 s. co m
</script>
</head>
<body>

<p>This is a p element.</p>
<div>This is a div element (next sibling of p).</div>

<p>This is a p element (next sibling of p).</p>
<h4>This is a h4 element (next sibling of p).</h4>
<h5>This is a h5 element (next sibling of p).</h5>

<p>This is a p element (next sibling of p).</p>
<span>This is a span element (next sibling of p).</span>

</body>
</html>

Related Tutorials