title: filter div from their id using jquery
body: <pre><code> &lt;ul&gt;
      &lt;li&gt;
           &lt;div class="link" id="contentLink20000002"&gt;
              &lt;a href="Link1" target="_blank"&gt;Link 1&lt;/a&gt;
           &lt;/div&gt;
      &lt;/li&gt;
       &lt;li&gt;
           &lt;div class="link" id="contentLink1000002"&gt;
             &lt;a href="Link2 target="_blank"&gt;Link 2&lt;/a&gt;
           &lt;/div&gt;
        &lt;/li&gt;
        &lt;li&gt;
           &lt;div class="link" id="contentLink2000003"&gt;
             &lt;a href="Link3" target="_blank"&gt;Link 3&lt;/a&gt;
           &lt;/div&gt;
        &lt;/li&gt;
         &lt;li&gt;
             &lt;div class="link" id="contentLink2000004"&gt;
               &lt;a href="Link 4" target="_blank"&gt;Link 4&lt;/a&gt;
             &lt;/div&gt;
         &lt;/li&gt;
       &lt;/ul&gt;
  </code></pre>
  
  <p>I have this structure an I am trying to separate id's which starts with 'contentLink2'. I have tried achieving this with .contains and regex but no luck so far. </p>
  
  <pre><code>var listids =  $('ul li div');
  listids.each(function(li){
   var contentId = $(this).filter('contentLink2').attr('id'); 
   console.log(contentId);
  });
  </code></pre>
  
  <p>What i am trying is to create navigation. Like </p>
  
  <p>Text</p>
  
  <ul>
  <li><p>link1</p></li>
  <li><p>link2</p></li>
  </ul>
  
  <p>Text</p>
  
  <ul>
  <li><p>link3</p></li>
  <li><p>link4</p></li>
  </ul>
  
  <p>HTML is dynamic so I don't have control it.</p>