我需要在我的canvas html代码中进行更改。我需要将canvas数据属性插入Java脚本或级联样式表中。我该怎么做,请帮助我。以下是我的代码。
<html>
<head>
<title>Gauge</title>
</head>
<body style="background: black">
<div style="text-align: center;">
<canvas data-type="radial-gauge"
data-width="400"
data-height="400"
data-title="false"
data-min-value="0"
data-max-value="100"
data-value="45"
data-animate-on-init="true"
data-major-ticks="0,20,40,60,80,100"
data-minor-ticks="4"
data-stroke-ticks="true"
data-color-major-ticks="#030303"
data-color-minor-ticks="#030303"
data-value-box="true"
data-animated-value="true"
data-borders="false"
data-border-shadow-width="0"
data-needle-type="arrow"
data-needle-width="2"
data-needle-circle-size="5"
data-needle-circle-outer="false"
data-needle-circle-inner="true"
data-animation-duration="2000"
data-animation-rule="linear"
data-ticks-angle="240"
data-start-angle="60"
></canvas>
</div>
</body>
</html>
答案 0 :(得分:0)
您自然可以使用以下命令将属性设置为元素:
element.setAttribute(attributename, attributevalue)