Is there a way to only index a specific element with in a parent? For example:
$('h4').click(function(){
alert($('div h4').index('h4'));
});
<div>
<p>do not include in indexing</p>
<p>do not include in indexing</p>
<p>do not include in indexing</p>
<p>do not include in indexing</p>
<h4>Tag I want to include in index</h4>
<h4>Tag I want to include in index</h4>
</div>
What I want from this is either an alert of 0 or 1 corresponding to the h4 tag I have clicked.
Is this possible with jquery?
Update
Thanks for all the answers, what most of what you guys have offered works, but in working practice it doesn’t seem to function. I guess I have issues somewhere else in my page.
Thanks Anyway
try this
fiddle example : http://jsfiddle.net/L84QV/