.nextAll()
In this chapter you will learn:
Syntax and Description
.nextAll([selector])
gets all following siblings of each element in the set of matched elements,
optionally filtered by a selector.
selector (optional)
is a string containing a selector
expression to match elements against.
Its return value is the new jQuery object.
Search tags from nextAll()
The following code selects disabled buttons
and then search span
tags from nextAll().
<html><!-- j a v a2s .co m-->
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button[disabled]").nextAll("span").text("data");
});
</script>
<style>
.y { background:yellow; }
</style>
</head>
<body>
<body>
<div><button disabled="disabled">First</button> - <span class="selected"></span>
<span></span>
</div>
</body>
</html>
Add style from the second
The following code select first div tag from the document
and calls nextAll()
method to get the rest..
<html><!--from j a v a 2 s . c om-->
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div:first").nextAll().css("color","red");
});
</script>
</head>
<body>
<body>
<div>java2s.com</div>
<div>j ava2s.com</div>
</body>
</html>
Next chapter...
What you will learn in the next chapter: