I have following html:
<div class="rows">
<div class="row"><input type="text" onchange="javascript:getIndex(this);" value="" /></div>
<div class="row"><input type="text" onchange="javascript:getIndex(this);" value="" /></div>
<div class="row"><input type="text" onchange="javascript:getIndex(this);" value="" /></div>
</div>
my function:
function getIndex(elem) {
var $i = $(elem).parent().parent();
alert($i.index($(elem).parent()));
}
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.
Has anyone experience this before?
Thanks
1 Answer