How I get ID table?

How I get ID table?

BelitaColaresBelitaColares Posts: 4Questions: 1Answers: 0
edited January 2016 in Free community support

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

Answers

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    .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.

  • BelitaColaresBelitaColares Posts: 4Questions: 1Answers: 0
    edited February 2016

    work's with table.tables().nodes().to$().attr('id').

    Thanks for the suggestion!

  • allanallan Posts: 61,821Questions: 1Answers: 10,127 Site admin
    Answer ✓

    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 be table.table().node().id.

    Allan

  • BelitaColaresBelitaColares Posts: 4Questions: 1Answers: 0

    Thanks ;))

This discussion has been closed.