Programming wisdom #476

Jun 06, 2011 15:40


Originally published at A Couple of Robots. You can comment here or there.

Changing innerHTML property of a form resets that form’s elements.

(For example, if you want to append a new element to a form before submitting it. If you do it using innerHTML += newElement, it will clear all the other elements in the form).

Use document.createElement+ element.setAttribute + element.appendChild instead.

dev

Previous post Next post
Up