JS 获取所有 HTML 定义的标签

JS 获取所有 HTML 定义的标签

在 HTML Standard 中,选中第一个表格元素,运行脚本得到的数组应用消除所有不合法标签\<Raw data={\` function removeAttributesAndNormali...

花野猫

花野猫

更新于 2023-11-05

2686

HTML Standard 中,选中第一个表格元素,运行脚本

js
[...document.querySelectorAll('[id^="elements-3:the-"][id$="-element"]')].map(e=>e.textContent)

得到的数组

js
[
"a",
"abbr",
"address",
"article",
"area",
"aside",
"audio",
"source",
"track",
"b",
"base",
"head",
"bdi",
"bdo",
"blockquote",
"body",
"html",
"br",
"button",
"canvas",
"caption",
"table",
"cite",
"code",
"col",
"colgroup",
"template",
"data",
"datalist",
"option",
"dd",
"dt",
"dl",
"div",
"del",
"details",
"summary",
"dfn",
"dialog",
"em",
"embed",
"fieldset",
"legend",
"figcaption",
"figure",
"footer",
"form",
"header",
"hgroup",
"hr",
"i",
"iframe",
"img",
"picture",
"input",
"ins",
"kbd",
"label",
"li",
"ol",
"ul",
"menu",
"link",
"noscript",
"main",
"map",
"mark",
"meta",
"meter",
"nav",
"object",
"optgroup",
"select",
"output",
"p",
"pre",
"progress",
"q",
"rp",
"ruby",
"rt",
"s",
"samp",
"script",
"search",
"section",
"slot",
"small",
"video",
"span",
"strong",
"style",
"thead",
"tbody",
"tfoot",
"tr",
"td",
"textarea",
"th",
"time",
"title",
"u",
"var",
"wbr"
]

应用

消除所有不合法标签


结果