title: how to get current input field index by jquery
body: <p>I have following html table layout:</p>
  
  <pre><code>&lt;table id="mytable"&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
      &lt;td&gt;&lt;input type="text" value="" /&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" value="" /&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" value="" /&gt;&lt;/td&gt;
      &lt;td&gt;Some cell text&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" value="" /&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;input type="text" value="" /&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" value="" /&gt;&lt;/td&gt;
      &lt;td&gt;Some cell text&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;Some cell text&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" value="" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
  
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I need to know the current input field index of respective row while click on any input field but can't figure out a way to get it. I can get total number of input fields (length) of each row by following formula:</p>
  
  <pre><code>var thisRow = $(this).closest('tr');
  var inputLength = thisRow.find('input[type="text"]').length;
  </code></pre>
  
  <p>As for example the <code>inputLength</code> for first row is <code>4</code> and second row is <code>3</code>. But how can I get the input index when a user clicks on 2nd input field of first row (it should be 1)?</p>
  
  <p>[note: I can't use <code>td</code> index as alternative of <code>input</code> field index as you may see that there might have been some <code>td</code> which have no <code>input</code> field. As a result, if I run a <code>for loop</code> it can't be performed as I expected.]</p>