/    Sign up×
Community /Pin to ProfileBookmark

Is it possible to get the width of table cell(s) that have been dynamically built

Goal:

To build a horizontal floating menu that matches the first row (header row) of my dynamically built table (to include text and cell height/width – needs to match exactly). I have accomplished 90% of this task by extracting the text and building the row in my floating menu header and placing the floating menu where it needs to be. However, I’m having a problem aligning the table (<TD></TD>) cells because of my dynamically built table.

Scenario:

I have a table that is built dynamically. Before it is displayed, I format the table row data (code that adds text/deletes rows etc…), which alters the width of all the table cells (via JavaScript). We’ll call this (for lack of a better phrase) “pre_floater_table_format_code.”

I then loop through the DOM (<TD></TD>) in the first row of the table to get the text and width from each cell (using offsetWidth and/or clientWidth) and assign the text and cell width(s) to variables that I use to build my floating menu with. We’ll call this (for lack of a better phrase) “get_cell_text_width_code.”

Problem:

The problem is that once the table is built (and before it is altered by the “pre_floater_table_format_code”) it seems as though my “get_cell_text_width_code” reads the un-processed table cell width(s) and sets these variables to the un-processed width values. The “pre_floater_table_format_code” runs much earlier than the “get_cell_text_width_code.” So why wouldn’t the “get_cell_text_width_code” read the cell width(s) after they’ve been adjusted by the “pre_floater_table_format_code?” Does this make sense? Anyone have any recommendations? Alternative solutions?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @douglasc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...