Index of div element jquery
<p>I have following html:</p>

<pre><code>&lt;div class="rows"&gt;
  &lt;div class="row"&gt;&lt;input type="text" onchange="javascript:getIndex(this);" value="" /&gt;&lt;/div&gt;
  &lt;div class="row"&gt;&lt;input type="text" onchange="javascript:getIndex(this);" value="" /&gt;&lt;/div&gt;
  &lt;div class="row"&gt;&lt;input type="text" onchange="javascript:getIndex(this);" value="" /&gt;&lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>my function:</p>

<pre><code>function getIndex(elem) {
    var $i = $(elem).parent().parent();
    alert($i.index($(elem).parent()));
}
</code></pre>

<p>I keep getting -1 telling me its not found... I looked into it and tried to spit out the value within the obj parent.
alert($(elem).parent().html());  this returns me the  tag with the default value that was changed...but if i alert $(obj).val() its totally different. So I am thinking that maybe the reason I keep getting a -1.</p>

<p>Has anyone experience this before?</p>

<p>Thanks</p>
