【发布时间】:2020-01-02 12:32:23
【问题描述】:
我使用 snap.svg 创建了一个 SVG 路径,您可以在下面看到它的代码。现在我正在尝试更改属性的值,例如strokeWidth。为此,我创建了一个文本输入框和一个按钮,该按钮运行一个应该为 strokeWidth 填充新值的函数。但它不起作用。我究竟做错了什么?有没有可能我什至不能改变价值?我还在下面发布了输入框和按钮的代码+我的用于更改笔画宽度的函数
我尝试了很多不同的功能和脚本,但似乎都没有。有时我收到一条错误消息,有时没有。当我收到一条错误消息时,它总是说函数未定义或 L_PUF_WAR 未定义。
var L_PUF_WAR = s.path("m 937.88689,516.10127 v -51.8831 H 573.37482 V 340.49692 H 391.11879 V 276.6408").attr({
fill: "none",
stroke: "#bada55",
strokeWidth: 15,
strokeDasharray: "30, 30 ,30"
});
A_PUF.append(L_PUF_WAR);```
<script>
function hallo(){
var number = document.getElementById("number").value;
if(number > 0){
L_PUF_WAR.strokeWidth = number;
}
}
</script>
<input type="text" id="number" name="number"/><br/>
<input type="button" value="breite" onclick="hallo()"/>
I am expecting to put in a value for the strokewidth into the Input Box for example 20 and then the strokeWidth should change to that value..
【问题讨论】:
标签: javascript html svg snap.svg