字符串转换成DOM对象:
const htmlString = "<div id='foo'><a href='#'>Link</a><span></span></div>"
const parser = new DOMParser()
const doc = parser.parseFromString(htmlString, 'text/html')
doc.body.firstChild // => <div id="foo">...
doc.body.firstChild.firstChild // => <a href="#">...
DOM对象转换成字符串: