简体   繁体   中英

How to create self closing html tag on the fly

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"/>

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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM