title: Jquery Select next sibling tab with condition
body: <p>I currently have this layout:</p>
  
  <pre><code>      _______________________________________________________
        |         X|         X|        X | &lt;display:|        X |
   _____|__________|__________|          |___none&gt;__|__________|_______________________
   |                                                                                   |
   |                                                                                   |
   |                                                                                   |
  </code></pre>
  
  <p>My plan is when I press 'X', is for the tab to:</p>
  
  <ul>
  <li>Inject style <code>display: none;</code></li>
  <li>Open The next tab/make next tab active.</li>
  </ul>
  
  <p>I'm currently using the Jquery:</p>
  
  <pre><code>    $('.k-image').click(function () {
          $(this).parent().parent().css("display","none");
      });
  </code></pre>
  
  <p>To 'close' the tab.I.e. Pressing the 'X' button closes the tab.</p>
  
  <p>And:</p>
  
  <pre><code>    $('#allocations').click(function (e) {
          $('.k-item').removeClass("k-state-active");
          $("[aria-controls=tabMain-2]").css("display", "initial");
      });
  </code></pre>
  
  <p>to open one.</p>
  
  <p>What I want is for the 'tab' and 'Content' to go to the <em>next available tab</em> when i 'close' a tab. This means to loop through the tabs, find which is 'not display: none' and display it.</p>
  
  <p>How can this be achieved using Jquery (select the next sibling in which display is not none <strong><em>and</em></strong> if it reaches the end, then start over from beginning)? </p>
  
  <p>Please note I'm using telerik tabstrip, and so here is a view of the page inspector:</p>
  
  <p><img src="https://i.stack.imgur.com/vaDO5.png" alt="enter image description here"></p>
  
  <p>For visibility issues, I have created a <a href="http://jsfiddle.net/jbutler483/eu0fe7pv/" rel="nofollow noreferrer">jsfiddle</a> in order to make the generated markup easier to read.</p>
  
  <p><strong>Please note</strong> </p>
  
  <p>I can close ony of the tabs, it doesn't have to be the active tab that i'm closing.</p>