Skip to content
Discussion options

You must be logged in to vote

I suggest three options

  1. JQuery
    This will return a Nodelist
const domNodes = $.parseHTML($('#parseme')[0].childNodes);
  1. jQuery parseHTML https://api.jquery.com/jquery.parsehtml/
    This will return an array.
const domNodes = $.parseHTML($('#parseme').html()));
  1. Javascript DOMParser https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
    This will return a XML Document
const domString = document.getElementById('parseme').innerHTML;
const parser = new DOMParser();
const domNodes = parser.parseFromString(domString,'text/html');

See all variants in action here (watch console) https://jsfiddle.net/lubber/zfybs7vx/

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lubber-de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants