Parse an HTML string with JS

后端 未结 10 1239
逝去的感伤
逝去的感伤 2020-11-21 07:17

I searched for a solution but nothing was relevant, so here is my problem:

I want to parse a string which contains HTML text. I want to do it in JavaScript.

10条回答
  •  清酒与你
    2020-11-21 07:46

    var doc = new DOMParser().parseFromString(html, "text/html");
    var links = doc.querySelectorAll("a");
    

提交回复
热议问题