Title: getElementById(table_id)
Last modified: May 24, 2023

---

# getElementById(table_id)

 *  Resolved [Aniket](https://wordpress.org/support/users/aniketdumbare/)
 * (@aniketdumbare)
 * [3 years ago](https://wordpress.org/support/topic/getelementbyidtable_id/)
 * Hello,
 * How to use getElementById() with tablepress tables? Today we observed that, on
   a page the table we had added, the table id which was being generated till yesterday(
   for last 6 months) was tablepress-<ID>-no-2 however all of a sudden today it 
   started having id tablepress-<ID> only.
 * On our page, we always had any such table only once and it was never used twice
   neither on the page nor on whole website. [https://tablepress.org/documentation/](https://tablepress.org/documentation/)
   for **tablepress-<ID>-no-<number>** describes the scenario.
 * However we never had such case. Which ID we should rely on to be used with getElementById()

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [3 years ago](https://wordpress.org/support/topic/getelementbyidtable_id/#post-16764355)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * Well, you would have to use the HTML that your table has on the page.
 * Normally, that is `tablepress-<ID>`. If the table has the HTML ID `tablepress-
   <ID>-no-2` (or higher numbers), this means that its rendering function has been
   called twice (or even more often). To not duplicate HTML IDs (as these need to
   unique), that `-no-...` is appended. Besides embedding a table on the same page
   twice (on purpose), this can e.g. happen if other plugins already (pre-)process
   the post/page content for whatever reason, before it is actually rendered.
 * (An alternative approach here, to be independent from the actual HTML ID, might
   be to check if the JavaScript code that you are running can be implemented as
   part of a “Custom Command”. In that, DataTables hooks, like [https://datatables.net/reference/option/initComplete](https://datatables.net/reference/option/initComplete)
   are available, which can also be used for post-processing, for example.)
 * Best wishes,
   Tobias
 *  Thread Starter [Aniket](https://wordpress.org/support/users/aniketdumbare/)
 * (@aniketdumbare)
 * [3 years ago](https://wordpress.org/support/topic/getelementbyidtable_id/#post-16764809)
 * Thank you! Let me check.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [3 years ago](https://wordpress.org/support/topic/getelementbyidtable_id/#post-16765852)
 * Hi,
 * sure! If there’s anything needed here from me, let me know.
 * Best wishes,
   Tobias

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘getElementById(table_id)’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/getelementbyidtable_id/#post-16765852)
 * Status: resolved