title: How to capture a string between two tags
body: <p>I'm working on writing a bookmarklet to enhance my workflow at work. Part of my job is obtaining the correct information to be placed into an email. I love JavaScript and jQuery, so I'm working on a way to make my job easier using this library.</p>
  
  <p>I'm targeting a website that has particularly odd markup. I need to capture the text after a matched label tag, and before the next label tag. This is all, oddly enough, inside a P tag. I have no clue why the website's developer decided to use label tags either... I am unable to modify the markup, so that's not an option. I've searched all across the web and haven't been able to find a working technique for my specific situation.</p>
  
  <p>I created a jsFiddle to demonstrate what I'm trying to do using the same kind of markup and CSS. I have no problem accessing the label, and I've used a few different methods to do so (in the fiddle, commented out) but I am still unable to properly "capture" the text in between the two label tags. The text will end up being placed into an alert so I can quickly copy it. I've tried using .nextUntil but have had no luck with it.</p>
  
  <p>Basically it would be something like this:</p>
  
  <pre><code>&lt;label&gt;item 1&lt;/label&gt; Content to capture
  &lt;br&gt;&lt;br&gt;
  &lt;label&gt;item 2&lt;/label&gt; Don't capture this...
  </code></pre>
  
  <p>I fear the reason my attempts aren't working is because (I think) <code>nextUntil()</code> tries to find the next object using the initial selector, so it's looking for the next label, rather than the text in between. I've tried using <code>$('selector').parent().nextUntil('label')</code> which also hasn't worked.</p>
  
  <hr>
  
  <p><strong>Here's the working example:</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function(){
    //$('p label:eq(0)')afterUntil('&lt;br&gt;').css('color', 'red');
    //$('p').find($('label:contains("item 1")')).nextUntil("&lt;label&gt;").css('color', 'red');
    $('p label:contains("item 1")').parent().nextUntil('label').css('color','red');
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>label {
    display:inline-block;    
    width:25%;
    font-weight:bold;
  }
  p {
    font-family:arial;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;p&gt;
    &lt;label&gt;item 1&lt;/label&gt; Capture me!&lt;br&gt;&lt;br&gt;
    &lt;label&gt;item 2&lt;/label&gt; Don't capture me
  &lt;/p&gt;</code></pre>
  </div>
  </div>
  
  (<strong>fiddle: <a href="http://jsfiddle.net/1c2LpzrL/1/" rel="nofollow">http://jsfiddle.net/1c2LpzrL/1/</a></strong>)</p>