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
jQuery是否提供了从virtual_dom
中删除段落的方法,以便console.log(virtual_dom)
只记录一个只有h1
标记的DOM,例如$('p').remove()
但影响{{1}而不是浏览器呈现的实际文档?
答案 0 :(得分:2)
答案 1 :(得分:0)
您的虚拟DOM是可遍历的,每个标记节点都是可移动的。
在FireBug或浏览器控制台中测试
var html = $('<div />');
html.append('<p /><p />').children(':last').text('Test');
console.log(html.html());
html.children(':first').remove();
console.log(html.html());