0

So I've learned parsing html with jQuery but now I'd like to know the pure javascript method.

A typical jQuery parse in my use would look like

function parse(obj) {
    // Parse the html
    var htm = $.parseHTML(obj, true);
    // reference whatever element I want in said parsed html
    $('#id', htm).text();
}

what would be the javascript equivalent of this? I'm mostly confused at referencing the parsed object in pure javascript vs jQuery.

Edit: This is being executed in a userscript, so I'd prefer not to add any dummy elements to the DOM of the site it's running on.

DjH
  • 1,448
  • 2
  • 22
  • 41
  • This question might have been answered here: http://stackoverflow.com/questions/10585029/parse-a-html-string-with-js – RickyTamma Jul 26 '16 at 22:48
  • @RickyTammy , ok, I should have mentioned this is being used in a userscript. So I don't want to risk injecting any new elements on the page it's running on. I used to use that method before I knew better. I'll edit the question to reflect this. – DjH Jul 26 '16 at 23:14

0 Answers0