Let us suppose I have this markup
First Hi Hello Second
Hi
Hello
You can use the index() function:
$('p').each(function(){ var index = $(this).index(); if(index > $("#first").index() && index < $("#second").index()) { // do stuff } });