我如何将类名添加到附加的创建的元素?

问题描述 投票:-1回答:1

Adding CLASS Name to an APPENDED-CREATED Element after APPENDED Once More as an ITEM

-注意元素,即附加到元素svg中的多边形。*目标是将类名称分配给svg-element中的polygon-element,然后使用javaScript <3

设置多边形的样式
javascript html styling appendchild
1个回答
0
投票

这是易于使用的课程

<html>
<body>
<p>Not appended</p>

<style>
.append{
color:white;
background:black;
}
</style><script type='text/javascript'>
//create append
var node = document.createElement("p"); 
//set the text
node.innerHTML='Appended text';

//append it!
document.body.appendChild(node);
//add the class
node.className = 'append';
</script>
</body>
</html>
© www.soinside.com 2019 - 2024. All rights reserved.