语法
js
removeItem(index)
参数
index-
要移除的项目的索引。
返回值
被移除的 DOMPoint 对象。
异常
NoModificationAllowedErrorDOMException-
如果列表是只读的,则会抛出此错误。
IndexSizeErrorDOMException-
如果传入的索引大于列表中的项数,则会抛出此异常。
示例
下面的示例展示了一个包含五个坐标对的 <polyline> 的 SVG。索引为 2 的项目被移除。
html
<svg id="svg" viewBox="-10 -10 120 120" xmlns="http://www.w3.org/2000/svg">
<polyline
id="example"
stroke="black"
fill="none"
points="50,0 21,90 98,35 2,35 79,90" />
</svg>
js
const example = document.getElementById("example");
console.log(example.points.removeItem(2));
规范
| 规范 |
|---|
| Scalable Vector Graphics (SVG) 2 # __svg__SVGNameList__removeItem |
浏览器兼容性
加载中…