Heading one
Heading two
heading caption
Heading three
Pass your index() a selector:
alert($("h3").eq(2).index("h3"));
<div>
<h3>Heading one</h3>
<h3>Heading two</h3>
<h4>heading caption</h4>
<h3>Heading three</h3>
</div>
<script type="text/javascript">
$(document).ready(function(){
$("div").children().each(function(){
$(this).click(function(){
alert($(this).context.innerHTML);
});
});
});
</script>`