I want to iterate through the table and save input values to the array, but I get js error:
Object doesn't support property of method 'find'
Here is my code:
function Elem(tex, check, r, c)
{
this.text = tex;
this.checkbox = check;
this.row = r;
this.column = c;
}
var Elems = [];
function fill()
{
var table = document.getElementById("tab");
for(var i=table.rows.length-1; i>=2; --i)
{
for(var j=table.rows[i].cells.length-1; j>=1 ; j=j-2)
{
var check = $(table.rows[i].cells[j-1]).find('input');
check = check.is(":checked");
var ans = $(table.rows[i].cells[j]).find('input');
ans = ans.val();
var ans = new Elem(ans, check, i, j/2);
Elems.push(ans);
}
}
}
And here is how my table looks:
...
<table id="tab">
<tr>
<td rowspan="2">
<strong>delete row</strong>
</td>
<td>
<strong>checkbox info</strong>
</td>
<td>
<strong>description</strong>
</td>
</tr>
<tr>
<td>
<strong>delete column</strong>
</td>
<td>
<input type='checkbox' name='delColumn_1'/>
</td>
</tr>
<tr>
<td>
<input type='checkbox' name="delRow_1"/>
</td>
<td>
<input type='checkbox' class='check' name="ele.check"/>
</td>
<td>
<input type='text' name="ele.text" required="required"/>
</td>
</tr>
</table>
...
And I want to get text value from ele.text and checkbox value from ele.check. I will be very grateful for help.
.find()is a jQuery method, meaning that you cannot use it without including the jQuery library. It's not a native DOM method.