Select frist from selected
Description
The following code shows how to select frist from selected.
Example
<!DOCTYPE html>
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
<!-- ww w .j a va 2s. co m-->
</script>
<script>
$(function() {
var listElements = $("li");
var firstEl = listElements.first();
var lastEl = listElements.last();
document.writeln("firstEl value:" + firstEl.html());
document.writeln("firstEl length:" + firstEl.length);
document.writeln("lastEl value:" + lastEl.html());
document.writeln("firstEl length:" + firstEl.length);
});
</script>
</head>
<body>
<ul>
<li>A</li>
<li>B</li>
<li>java 2s.com</li>
</ul>
</body>
</html>