Hello There, Guest! Login Register
Advertise Here | Remove Ads

How to get a value inside a <td> with JS

  • 0 Vote(s) - 0 Average


11-01-2016, 05:21 PM #1
Riyad Offline FFU JUNIOR FFU JUNIOR
Posts:2,315 Threads:1,981 Joined:Jan 2016 Reputation: 0 Sex Male
Country: Bangladesh
Hi,
I have a table and ther fist column in my table is a hidden column with the item ID, the second column is a colum with a checkbox, I need a function that returs the ID os each item that has the checkbox clicked. Here is what I've done bur it1s not working.
Code:
function processaCheckbox() {
var chk = document.getElementsByClassName("td-checkbox");
var ids = [];
for (var i = 0; i < chk.length; i++) {
var element = chk[i];
var tr = element.closest("tr");
if (tr.children[1].children[0].checked == true) {
ids[i] = tr.children[0].text();
}
}
return ids;
}






Forum Jump:


Users browsing this thread:1 Guest(s)

Advertise Here | Remove Ads