我使用数据表单元格内的复选框,并选中一个或多个复选框后,显示“添加”按钮进行更改。但是我的问题是我在选中复选框后无法从单元格中获取值。如果我可以采用已选中复选框的值,则可以将其发送到数据表中进行必要的更改
<td class="denetleme">
<div class="vs-checkbox-con vs-checkbox-success">
<input class="selectAll_1 selectinput" type="checkbox" value="true" >
<span class="vs-checkbox">
<span class="vs-checkbox--check">
<i class="vs-icon feather icon-check"></i>
</span>
</span>
</div>
</td>
如果一行中选中了一个或多个复选框,则还要选中这些复选框和列ID
答案 0 :(得分:0)
您可以使用.selectinput
$('#mytable .selectinput').each(function() {
alert($(this).html());
});
答案 1 :(得分:0)
$('#saveBtn').click(function () {
var dataArr = [];
$.each($("#genelTablo tr.selected td.checkElement input.selectinput"), function () { //get each tr which has selected class
var getColumnOfTd = $(this).closest("td")
console.log("column", table.cell(getColumnOfTd).index().column, table.cell(getColumnOfTd).index().row)
dataArr.push({
columnName: $(this).closest("tr").find("td:first-child").text(),
columnId: table.cell(getColumnOfTd).index().column,
rowId: table.cell(getColumnOfTd).index().row,
inputValue: $(this).val()
})
//dataArr.push($(this).find('td.checkElement input').val()); //find its first td and push the value
//dataArr.push($(this).find('td:first').text()); You can use this too
});
console.log("here",dataArr);
});