Map selected elements
Description
The following code shows how to map parents to get its 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() {<!-- w w w. j a v a 2 s .c om-->
var parentEls = $("span").parents().map(function() {
return this.tagName;
}).get().join(", ");
$("span").append(parentEls);
});
</script>
</head>
<body>
<body>
<div>
<p>
<span> </span>
</p>
</div>
</body>
</html>