Now here’s a script we can get behind… Dan Webb’s DOM Builder combines the ease of innerHTML with the precision of DOM methods.Skip to comment form
- You can use the non-standard
innerHTMLwhich is quick and easy but proprietary or
- You can use standards: DOM methods like
createTextNodewhich carry the W3C’s stamp of approval but which can be finicky and repetitive to use.
Like all the best solutions, it does one thing really well instead of trying to be all things to all people. This 1K file will prove invaluable to anyone who’s been faced with the same dilemma. It’s a guilt-free way of painlessly adding nodes to the DOM tree.
- #1 On April 13th, 2006 8:33 pm