Show a hidden div or create new with DOM?

Discussion in 'JavaScript' started by rodney88, Apr 18, 2007.

  1. #1
    Is it better to
    (1) create a hidden div in the original HTML document (display:none) and simply update the style to show it (display:block)
    or (2) use dom functions (appendChild, etc.) to create the div where needed and fill it with innerHTML?

    I realise there's not usually a "best" way of doing something, but I mean which would be most cross-browser compatible, quickest, 'best practice'?

    Note this is only for browsers already with javascript enabled - normally I would use method one so that the content is always accessible (regardless of whether the user or even search engine bot has javascript or not) but that isn't needed for this project.

    I'm also using the mootools framework if that makes a difference..
     
    rodney88, Apr 18, 2007 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    number one the less code the better IMO
     
    krakjoe, Apr 18, 2007 IP