Get all parents name
Description
The following code shows how to get all parents name.
Example
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {<!--from www .j a v a 2s .com-->
var parentEls = $("span").parents().map(function() {
return this.tagName;
}).get().join(", ");
$("span").append(parentEls);
});
</script>
</head>
<body>
<div>
<p>
<span> </span>
</p>
</div>
</body>
</html>