Jump to content

FireFox Table Data cells shifting using innerHTML?


galvin

Recommended Posts

This might not be answerable without seeing ALL of my code, but just curious if anyone is aware of why in FireFox, innerHTML inserts into Table Data cells cause the Table Data cells to shift from where they should be.  I have a basic TR like below, where it's five TDs across ONE TR.... 

 



<tr>
<td class="answer" id="answer0"> </td>
<td class="answer" id="answer1"> </td>
<td class="answer" id="answer2"> </td>
<td class="answer" id="answer3"> </td>
<td class="answer" id="answer4"> </td>
</tr>

 

In IE, it stays this way just fine, after I use innerHTML inserts.  But in FireFox, I fill in say, the 2nd Data cell using innerHTML and it appears fine.  Then I fill in the 1st Data cell using innerHTML and it appears fine, but the 2nd Data Cell moves and relocates UNDER the 1st Data Cell.  In other words, it moves to another TR that was NEVER THERE TO BEGIN WITH.

 

As an example, after I enter do some innerHTMLs in IE, the table structure stays exactly the same as it started (see above code).  But in Firefox, my ultimate Table has this type of wacked-out structure...

 

<tr>
<td class="answer" id="answer0">text</td>
<td class="answer" id="answer3">text</td>
</tr>
<tr>
<td class="answer" id="answer1">text</td>
<td class="answer" id="answer2">text</td>
<td class="answer" id="answer4">text</td>
</tr>

 

I am going nuts trying to figure this out. Any thoughts of what could cause this?

 

Link to comment
Share on other sites

Just found this on Google....

 

Problem:
IE supports innerHTML for table cells and FireFox doesn’t.

Solution:
You have to embed a div within the table cell and perform all innerHTML calls on that.

 

This actually works, but that seems ridiculous to have to put a DIV inside every TD.  Unless anyone has any thoughts other thoughts, I guess that's what I'll have to do.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.