hankknight
asked on
jQuery: Append to last <li> in string
How can I append to the last <li> inside a string? I don't ever want the string to be on the page. It should stay a string.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Examples</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var xyz='<li>1</li><li>2</li><li>3</li>';
xyz = $(xyz).find('li').last().append(' <span>LIST LI ITEM</span> ');
alert(xyz);
var xyz='<div><ul><li>1</li><li>2</li><li>3</li><ul><div>';
xyz = $(xyz).find('li').last().append(' <span>LIST LI ITEM</span> ');
alert(xyz);
});
</script>
</head>
<body>
</body>
</html>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window