elem.innerHTML =“<body></body>”无效。为什么?
elem.innerHTML = "<body></body>" isn't working. Why?
let t=document.createElement('template');
t.innerHTML = "<body></body>"
var E = t.children; // HTMLCollection { length: 0 }
t.innerHTML = "<div></div>";
var E = t.children; // HTMLCollection { 0: div, length: 1 }
正在解析 div 而不是正文,为什么正文标签没有被解析?
我在 windows 10
上使用 Firefox 99.0.1
Template elements 不允许包含正文元素。
时说
A start tag whose tag name is "body" … if there is a template element on the stack of open elements, then ignore the token.
let t=document.createElement('template');
t.innerHTML = "<body></body>"
var E = t.children; // HTMLCollection { length: 0 }
t.innerHTML = "<div></div>";
var E = t.children; // HTMLCollection { 0: div, length: 1 }
正在解析 div 而不是正文,为什么正文标签没有被解析?
我在 windows 10
上使用 Firefox 99.0.1Template elements 不允许包含正文元素。
时说A start tag whose tag name is "body" … if there is a template element on the stack of open elements, then ignore the token.