.get()
In this chapter you will learn:
Description
.get()
accepts a zero-based index as its argument and
returns the element at that index.
Get list element by index
The following code shows how to get the list element by index.
<!DOCTYPE html><!--from j a v a 2s .co m-->
<html>
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js">
</script>
<script>
$(function(){
var listElements = $("li");
var secondEl = listElements.get(2);
var fourthEl = listElements.get(3);
document.writeln(secondEl.innerHTML + " and " + fourthEl.innerHTML);
});
</script>
</head>
<body>
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
<li>D</li>
<li>E</li>
<li>F</li>
</ul>
</body>
</html>
Next chapter...
What you will learn in the next chapter: