problem with removeChild in IE

Discussion in 'JavaScript' started by hawkseye, Feb 15, 2008.

  1. #1
    hi,
    im trying to remove LI from one UL and adding it in another. my code works fine in FF but not in IE. please can u tell me what im doing wrong. the problem is that it does not remove the node.

    function removeNode(nodeId) {
    var ul = document.getElementById("boxes");
    var myLi = document.getElementById(nodeId);

    myLi.removeChild(document.getElementById("img_"+nodeId));
    myLi.removeChild(document.getElementById("br_"+nodeId));
    ul.removeChild(document.getElementById(nodeId));

    var topUl = document.getElementById("boxes1");
    myLi.className = "box1";
    myLi.onclick = function(){moveChild(nodeId)};
    topUl.appendChild(myLi);
    }
     
    hawkseye, Feb 15, 2008 IP
  2. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This might not be the problem but replace
    myLi.onclick = function(){moveChild(nodeId)};
    Code (markup):
    with
    myLi.onclick = function(){moveChild(nodeId);};
    Code (markup):
    or

    myLi.onclick = function(){
    	moveChild(nodeId);
    };
    Code (markup):
     
    MMJ, Feb 15, 2008 IP
  3. hawkseye

    hawkseye Peon

    Messages:
    10
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    did that but didnt make any difference
     
    hawkseye, Feb 15, 2008 IP
  4. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm not a JavaScript expert so this is probably correct but it just seems weird to me:

    var myLi = document.getElementById(nodeId);
    ---
    ul.removeChild(document.getElementById(nodeId));
    ---
    myLi.className = "box1";
    myLi.onclick = function(){moveChild(nodeId)};
    topUl.appendChild(myLi);
    HTML:
    The child you removed seems to be the exact same as myLi and if you've removed it from its parent, does it actually still exist? Just wondering since you were able to set the classname and such of it later.
     
    zerxer, Feb 15, 2008 IP