`)[0] which would result in `)[0] which would result in `)[0] which would result in

How to create self closing html tag on the fly

177 views Asked by At

I'm able to create an element like :

$(`<Override PartName="/xl/worksheets/sheet1.xml"/>`)[0]

which would result in <override partname="/xl/worksheets/sheet1.xml"></override>

How would I create element that would result in a self closing tag like below?

<Override PartName="/xl/worksheets/sheet1.xml"/>
1

There are 1 answers

1
Quentin On

jQuery deals with the DOM, not with tags. It creates an override element. There's no way to tell the browser to serialize it to a self-closing tag instead of a start and end tag.

(You'll also note that it is normalising the casing of the element type and attribute names. Don't use HTML DOM tools to process XML. They aren't designed for it.)