By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,044 Members | 1,248 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,044 IT Pros & Developers. It's quick & easy.

  does not render properly with document.createTextNode

P: 69
Hi,

I'm having trouble creating a blank table row in Javascript using document.createElement( ' ' ). When I look at the generated source it has intrepreted it as
Expand|Select|Wrap|Line Numbers
  1. <td>&amp;nbsp;</td>
. What do I need to do? I've tried using single quotes, double quotes and backslash.

Thanks,

Sean
Oct 23 '07 #1
Share this Question
Share on Google+
7 Replies


acoder
Expert Mod 15k+
P: 16,027
&nbsp; is not an element.

Do you want something like:
[HTML]<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>[/HTML]
Oct 23 '07 #2

P: 69
Yes that's exactly what I want.

&nbsp; is not an element.

Do you want something like:
[HTML]<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>[/HTML]
Oct 23 '07 #3

gits
Expert Mod 5K+
P: 5,390
hi ...

try to use

Expand|Select|Wrap|Line Numbers
  1. document.createTextNode('&nbsp;');
instead of createElement ...

kind regards
Oct 23 '07 #4

P: 69
Hi,

I was being a complete hipster doffus with the post because that's what I was doing anyway. What I've got is:

Expand|Select|Wrap|Line Numbers
  1. row = document.createElement( "tr" );
  2. column = document.createElement( "td" );
  3. var columnText = document.createTextNode('&nbsp;');
  4. column.appendChild( columnText );
  5. row.appendChild( column );
  6.  
  7. var theTable = document.getElementById('articleContents');
  8. theTable.tBodies[0].appendChild(row);
  9.  
Cheers,

Sean

hi ...

try to use

Expand|Select|Wrap|Line Numbers
  1. document.createTextNode('&nbsp;');
instead of createElement ...

kind regards
Oct 24 '07 #5

acoder
Expert Mod 15k+
P: 16,027
Hi,

I was being a complete hipster doffus with the post because that's what I was doing anyway.
So you had it working all along? Is there only one column in your table?
Oct 24 '07 #6

P: 69
No it still doesn't work. When I supply
Expand|Select|Wrap|Line Numbers
  1. '&nbsp'
to createTextNode in the generated source it's shown as
Expand|Select|Wrap|Line Numbers
  1. <td>&amp;nbsp;</td>
So you had it working all along? Is there only one column in your table?
Oct 24 '07 #7

acoder
Expert Mod 15k+
P: 16,027
Ah right, I see what you mean now. I've changed the thread title accordingly.

Try using unicode, e.g. "\u00a0".
Oct 24 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.