How do I get a hidden td element?
How do I get a hidden td element?
herbyxxx
Posts: 1Questions: 1Answers: 0
HTML:
<table id="table">
<thead>
<tr>
<th>Index</th>
<th>Some headline</th>
</tr>
</thead>
<tbody>
<tr>
<td data-link="somelink">1</td>
<td>Some information</td>
</tr>
</tbody>
</table>
JavaScript:
var table = $('#table').DataTable({
'columnDefs': [
{'targets': [0], 'visible': false}
]
});
$(document).on('click', '#table tbody tr', function () {
let td = table.row(this).data()[0];
//get data-href attribute???
});
With this I just get the text inside the hidden td (number 1). But I actually like to have to whole td or atleast access the data-link attribute.
How do I achieve this? Thanks
This discussion has been closed.
Answers
some thing like this
this contain only the row element not td, you need access it by child or by cells
in this example I show how to access it by cells each attri. it exists attributes,
$(this)[0].cells[1].attributes that you can scan if the attribute exists or not as well.
I choice not do that in this example instead I using try and catch.
Now with childnode