SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    innerHTML causes blank space to appear in an element

    Hi,

    I have an element that I dynamically update with child elements using JavaScript. At some point, I wish to clear all the content from the element.

    However, using

    myElement.innerHTML = "";

    cause extraneous blank space to be displayed. Exactly the same thing happens when using the Prototypejs method Element.update("");.

    Any ideas?

    Thanks,

    Jake.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Code javascript:
    while (el.firstChild) {
        el.removeChild(el.firstChild);
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •