does not render properly with document.createTextNode

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sebarry
    New Member
    • Jul 2007
    • 69

      does not render properly with document.createTextNode

    Hi,

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

    Thanks,

    Sean
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    &nbsp; is not an element.

    Do you want something like:
    [HTML]<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>[/HTML]

    Comment

    • Sebarry
      New Member
      • Jul 2007
      • 69

      #3
      Yes that's exactly what I want.

      Originally posted by acoder
      &nbsp; is not an element.

      Do you want something like:
      [HTML]<tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      </tr>[/HTML]

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        hi ...

        try to use

        [CODE=javascript]document.create TextNode('&nbsp ;');[/CODE] instead of createElement ...

        kind regards

        Comment

        • Sebarry
          New Member
          • Jul 2007
          • 69

          #5
          Hi,

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

          Code:
          row = document.createElement( "tr" );
          column = document.createElement( "td" );
          var columnText = document.createTextNode('&nbsp;');
          column.appendChild( columnText );
          row.appendChild( column );
          	
          var theTable = document.getElementById('articleContents');
          theTable.tBodies[0].appendChild(row);
          Cheers,

          Sean

          Originally posted by gits
          hi ...

          try to use

          [CODE=javascript]document.create TextNode('&nbsp ;');[/CODE] instead of createElement ...

          kind regards

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by Sebarry
            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?

            Comment

            • Sebarry
              New Member
              • Jul 2007
              • 69

              #7
              No it still doesn't work. When I supply
              Code:
              '&nbsp'
              to createTextNode in the generated source it's shown as
              Code:
              <td>&amp;nbsp;</td>
              Originally posted by acoder
              So you had it working all along? Is there only one column in your table?

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Ah right, I see what you mean now. I've changed the thread title accordingly.

                Try using unicode, e.g. "\u00a0".

                Comment

                Working...