js 给当前的 useElement 添加节点 const svgString = svg xmlns=httpwwww3org2000svg width=11893ex height=2072ex role=img focusable=false viewBox=0 -8339 52567 9159 xmlnsxlink=httpwwww3org1999xlink aria-hidden=
To add a node to the current useElement, you can use the appendChild method. Here's an example of how you can do it:
for (let i = 0; i < useElements.length; i++) {
const useElement = useElements[i];
const xlinkHref = useElement.getAttribute("xlink:href");
const newxlinkHref = xlinkHref.replace('#', '');
// Create a new node
const newNode = document.createElement('circle');
newNode.setAttribute('cx', '50');
newNode.setAttribute('cy', '50');
newNode.setAttribute('r', '20');
newNode.setAttribute('fill', 'red');
// Append the new node to the useElement
useElement.appendChild(newNode);
}
In this example, a new <circle> element is created and appended to each useElement. You can customize the attributes of the new node according to your needs.
原文地址: https://www.cveoy.top/t/topic/ik0o 著作权归作者所有。请勿转载和采集!