title: How to find selected row using jquery
body: <p>I have a table and a button to get the selected row:</p>
  
  <pre><code>&lt;table id="mytable" class="table-striped"&gt;
      &lt;tbody&gt;
          &lt;tr id="1"&gt;&lt;td&gt;Test1&lt;/td&gt;&lt;/tr&gt;
          &lt;tr id="2"&gt;&lt;td&gt;Test2&lt;/td&gt;&lt;/tr&gt;
          &lt;tr id="3"&gt;&lt;td&gt;Test3&lt;/td&gt;&lt;/tr&gt;
          &lt;tr id="4"&gt;&lt;td&gt;Test4&lt;/td&gt;&lt;/tr&gt;
          &lt;tr id="5"&gt;&lt;td&gt;Test5&lt;/td&gt;&lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;button id="btn"&gt;Get Selected Row&lt;/button&gt;
  </code></pre>
  
  <p>When I clicked the row I set the background color into red.</p>
  
  <pre><code>$('#mytable').on('click', 'tbody tr', function (event) {
      $(this).addClass('highlight').siblings().removeClass('highlight');
  });
  
  function getRow() {
      $('table &gt; tbody &gt; tr').find('background-color: red');
  }
  
  $('#btn').click(function (e) {
      var selrow = getRow();
      console.log(selrow);
      if (selrow != undefined)
          alert(selrow.attr('id'));
      else
          alert('undefined');
  });
  </code></pre>
  
  <p>The question is how to get the selected row (where background color is red) using jquery, when I clicked the button?</p>
  
  <p>Here is what I've done: <a href="http://jsfiddle.net/xu2AH/865/" rel="nofollow">http://jsfiddle.net/xu2AH/865/</a></p>