remove()
方法用于从当前Cell的父元素中移除它本身。该方法无需传入任何参数。
cell.remove();
该方法无需任何参数。
该方法没有返回值。
let container = yuka.createCell('div');
let child1 = yuka.createCell('p');
let child2 = yuka.createCell('span');
container.append(child1, child2);
child1.remove();
console.log(container.children); // [child2]
该示例中,创建了一个div
的Cell并设置为container
,然后创建了两个子Cell
,child1
和child2
,并将它们添加到了container
中。然后调用child1
的remove()
方法将其从container
中移除。最终,container
的子元素只剩下child2
。