I am trying to get the table rowIndex from a td element in jQuery. This is what I'm trying:
var element = $('td').filter(function() {
var Text = $(this).contents()[0].textContent.trim();
return parseInt(Text, 10) == some_Textvar;
});
var parent = element.parentNode;
var index = parent.rowIndex;
I'm getting the following error
Uncaught TypeError: Cannot read property 'rowIndex' of undefined(…)
html:
<div class="class1">
<table class="class2">
<tbody>
<tr>
<td>
</td>
</tr>
<tr>
......
The element definitely exists because I work with it in the rest of my code. How can I get this row which this td element is in?
Thanks
html.