innerHTML was a microsoft extension and is now part of the HTML5 standard. So, both are now 'professional'.
On Dec 22, 4:02 am, Kelvin Wu <[email protected]> wrote: > Hi, > > A little bit off tipoc, not related to iUI but I am thinking of the question > about Javascript performance, especially on mobile phone. > > To write HTML code in your Javascript, you can write DOM directly such as: > > var cellTitle = document.createElement("td"); > cell.className = "TableCell3"; > var labelTitle = document.createElement("lable"); > labelTitle.className = "LabelTitle"; > labelTitle.innerHTML = title; > cellTitle.appendChild(labelTitle); > rowTitle.appendChild(cellTitle); > > Or simply filling in innerHTML: > > root.innerHTML += "<td class=TableCell3><lable class=LabelTitle>" + title + > "</lable></td>"; > > The above two work exactly same. The first one looks more "professional" > while I personally feel that the second one could be much faster and less > CPU usage (less battery consumption), when you have a complicated HTML page, > you may need to carefully write hundreds of lines for DOM objects or, just > copy and paste HTML code to innerHTML... > > So my question is, is that true, using innerHTML is generally faster than > creating DOM? > > -- > > Sent from my mobile device. Ignore the typos unless they're funny. -- You received this message because you are subscribed to the Google Groups "iPhoneWebDev" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/iphonewebdev?hl=en.
