DocumentFragments に tr、th、または td タグを含めることは可能ですか?
私がこれを行う場合:
var template = document.createRange().createContextualFragment(
'<table></table>'
);
console.log(template.childNodes);
の出力が得られます[table]
。
私がこれを行う場合:
var template = document.createRange().createContextualFragment(
'<td></td>'
);
console.log(template.childNodes);
[]
!?!?の出力が得られます。
私がこれを行う場合:
var template = document.createRange().createContextualFragment(
'<td><p></p></td>'
);
console.log(template.childNodes);
[p]
??!?!?!??!?!??!を取得します。
そして最後に、これを行うと:
var template = document.createRange().createContextualFragment(
'<span><td></td></span>'
);
console.log(template.childNodes);
わかった[span]
- td はどこへ行った??!
ここの矛盾がわかりません。ドキュメントフラグメントが特定の要素のみを保持することは可能ですか? 私がやりたいことは、上記の 2 番目と同様のことを行い、 を使用して td を取得することquerySelector
です。
ありがとう