How I get ID table?
How I get ID table?
BelitaColares
Posts: 4Questions: 1Answers: 0
I need to get to ID table example: <table id="#myTable"></table>.
In old version works with $(table).attr('id')
but when i use new API .DataTable();
the attribute can not be found.
sorry my english.
Can someone help me?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
.DataTable() is applied to an element normally, so you should already know the table ID.
var myTable = $("#example").DataTable({ ... options ... }).
I already know that "example" is my id.
But, $(myTable).attr("id"), or sometimes .prop("id") should still work fine.
work's with
table.tables().nodes().to$().attr('id')
.Thanks for the suggestion!
Sounds like your
table
variable is the result of$().DataTable()
and therefore is not a jQuery object. As such, your method to get the table is correct. The other option would betable.table().node().id
.Allan
Thanks ;))