我希望能够选择SVG中的最后一个路径并将其删除。我尝试了多种方法,使用纯JavaScript和jQuery,但好像无法正确访问SVG或其路径。
HTML:
然而,我无法像选择其他元素一样选中SVG并查看其路径内容... 我的目标类似于:
HTML:
<div id="thesvgwrapper">
<svg id="thesvg"...><path ....></path><path ...></svg>
</div>
我可以使用以下方法清除SVG:
$('svg#thesvg').empty();
我可以使用以下方法查看SVG的内容:
var svgwrapper = $('#svgwrapper');
var svgcontents = $(svgwrapper).html();
alert(svgcontents);
然而,我无法像选择其他元素一样选中SVG并查看其路径内容... 我的目标类似于:
$('#thesvg path:last').remove();
thanks a million for any help