html tag parse #2367
Answered
by
lubber-de
niuzhi
asked this question in
Elements (button, image, label, loader, ...)
html tag parse
#2367
-
How to use semantic to parse html tag string? |
Beta Was this translation helpful? Give feedback.
Answered by
lubber-de
May 10, 2022
Replies: 1 comment
-
I suggest three options
const domNodes = $.parseHTML($('#parseme')[0].childNodes);
const domNodes = $.parseHTML($('#parseme').html()));
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/ |
Beta Was this translation helpful? Give feedback.
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
I suggest three options
This will return a Nodelist
This will return an array.
This will return a XML Document
See all variants in action here (watch console) https://jsfiddle.net/lubber/zfybs7vx/