IE innerHTML and Ordered/Unordered Lists

Discussion in 'JavaScript' started by nevetS, Jul 28, 2006.

  1. #1
    I'm having a heck of a time here. I can't seem to figure this out.

    I want to insert an ordered list into a page using javascript.

    The following code works fine in firefox, but I can't figure out a way to make it work in IE:

    
    document.getElementById("myplace").innerHTML="Here is my list: <ol><li>first</li><li>second</li></ol> there.";
    
    PHP:
    I can't even find a page where somebody mentions having the same problem, let alone someone who found a solution. If I remove the list tags, it works fine:

    
                document.getElementById("myplace").innerHTML="Here is my list: first second there.";
    
    PHP:
     
    nevetS, Jul 28, 2006 IP
  2. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Of course, the answer was extremely simple once I had a night of rest. As it turns out, firefox allowed me to put an ordered list inside a paragraph element, whereas IE did not. I changed the element to a div and it worked straight away.

    I was really dreading building everything with DOM. :)
     
    nevetS, Jul 28, 2006 IP