I have the following table:
function returnTable() {
return `
<table class="table table-striped table-bordered table-condensed">\
<tbody><tr>\
<th>Type</th>\
<th>Description</th>\
<td class="table-number">$0</td>\
<td class="table-number">$0</td>\
</tr>\
</tbody></table>
`
}
I want to be able to parse it with node using selectors. I see that document.queryselector appears to require a full html document.
I also tried:
function getTable1(page) {
const newTable = document.createElement(page);
console.log(newTable);
}
getTable1(returnTable())
But this gives:
const newTable = document.createElement(page);
^
ReferenceError: document is not defined
How to I parse an html substring in node? in other words use queryselector on a html fragment or substring?