html = '<h1>foo</h1><p>bar</p>';
virtual_dom = $(html);
console.log(virtual_dom);
// logs a data structure recognizable as a DOM with the h1 and p from the string
Does jQuery provide a way to remove paragraphs from virtual_dom, such that console.log(virtual_dom) will log a DOM with only a h1 tag, like $('p').remove() but affecting virtual_dom instead of the actual document rendered by the browser?
Use .filter(), for example:
virtual_dom = $(html).filter(":not(p)");
This will exclude all paragraphs from your html.
DEMO.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With