title: Select a row from html table and send values onclick of a button
body: <p>I have HTML table where I need to select a row and send its first cell ID to a button and <code>onclick</code> of the button send the selected value to a function in Javascript. How can I achieve this?</p>
  
  <p><strong>test.html</strong> :</p>
  
  <pre><code>&lt;table id="table"&gt;
          &lt;tr&gt;
              &lt;td&gt;1 Ferrari F138&lt;/td&gt;
              &lt;td&gt;1 000€&lt;/td&gt;
              &lt;td&gt;1 200€&lt;/td&gt;
  
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;2 Ferrari F138&lt;/td&gt;
              &lt;td&gt;1 000€&lt;/td&gt;
              &lt;td&gt;1 200€&lt;/td&gt;
  
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;3 Ferrari F138&lt;/td&gt;
              &lt;td&gt;1 000€&lt;/td&gt;
              &lt;td&gt;1 200€&lt;/td&gt;
  
          &lt;/tr&gt;
      &lt;/table&gt;
      &lt;input type="button" id="tst" value="OK" onclick="fnselect()" /&gt;
  </code></pre>
  
  <p><strong>test.js</strong> :</p>
  
  <pre><code>var table = document.getElementById('table'),
      selected = table.getElementsByClassName('selected');
  table.onclick = highlight;
  function highlight(e) {
      if (selected[0]) selected[0].className = '';
      e.target.parentNode.className = 'selected';
  }
  function fnselect(){
  var $row=$(this).parent().find('td');
      var clickeedID=$row.eq(0).text();
      alert(clickeedID);
  }
  </code></pre>
  
  <p><strong>test.css</strong> :</p>
  
  <pre><code>td {border: 1px #DDD solid; padding: 5px; cursor: pointer;}
  
  .selected {
      background-color: brown;
      color: #FFF;
  }
  </code></pre>
  
  <p>This is a fiddle of my problem <a href="http://jsfiddle.net/Z22NU/1/">JSFIDDLE</a></p>
  
  <p>I need to send the selected row's first cell value to a javascript function. But when the user selects a row and clicks on 'OK' button I should send the value to the function. How to do this?</p>