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.
The following function parseHTML
will return either :
a Document when your file starts with a doctype.
a DocumentFragment when your file doesn't start with a doctype.
function parseHTML(markup) {
if (markup.toLowerCase().trim().indexOf('
var links = parseHTML('Link 1Link 2').getElementsByTagName('a');