forked from SyncfusionSuccinctlyE-Books/jQuery-Succinctly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample027.html
31 lines (31 loc) · 912 Bytes
/
sample027.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html lang="en">
<body>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
<ul>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
</ul>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script> (function ($) {
// Remember that text() combines the contents of all
// elements in the wrapper set into a single string.
alert('there are ' + $('li').length + ' elements in the set');
// Get me the first element in the set
alert($('li:first').text()); // Alerts "1"
// Get me the last element in the set
alert($('li:last').text()); // Alerts "10"
// Get me the 6th element in the set, 0 based index
alert($('li:eq(5)').text()); // Alerts "6"
})(jQuery); </script>
</body>
</html>