Get html string from element
Description
The following code shows how to get html string from element.
Example
<!DOCTYPE html>
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script><!--from ww w . j a v a2 s. com-->
<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>