Possible Duplicate:
How to create xhtml elements with javascript
Creating a <br /> with javascript createElement?
I'm working with the programmatic generation of forms with JavaScript, e.g.:
document.createElement();
document.appendChild;
inputExample.type = "text";
…
but I realized that the JavaScript generation of self-closing [X]HTML/XML elements isn't applicable, i.e.
document.createElement('input');
will result in <input>, not <input />.
While the page has a
<!DOCTYPE html>
and
<html xmlns="http://www.w3.org/1999/xhtml">…</html>
and is part of a browser extension thus being interpreted with a MIME type of text/html, therefore not needing to syntactically conform to XHTML, I would like to know of a way for JavaScript element creation to generate valid XHTML. Is there a way to do this?