HTML String to DOM Node

DOMParser().parseFormString()

// case 1
let doc = new DOMParser().parseFromString('

123

', 'text/html') console.log(doc) // case 2 let doc = new DOMParser().parseFromString('

123

', 'text/xml') console.log(doc)

document.createRange().createContextualFragment()

let frag = document.createRange().createContextualFragment('
One
Two
') console.log(frag)

你可能感兴趣的:(HTML String to DOM Node)