繁体   English   中英

如何使用 JQuery 修改 SVG 的宽度

[英]How to modify the width of SVGs with JQuery

我正在使用 Articulate Storyline,我想修改我在软件中使用Javascript创建的线条的宽度

我已经知道我可以使用这行代码select任何项目(每个项目都导出到 Storyline 输出中的 SVG):

 var item = $('[aria-label="Ourline"] svg')

然后我们应该可以做一些 jQuery 动画...

问题是我无法使用以下代码修改所选行的宽度属性:

 $(item).attr("width","500");

它只是将 500 px 行的 position 向右更改? 什么?!

任何建议,将不胜感激。

请注意:这个问题与 Storyline 无关,都是关于 SVG 和 jquery。

https://jsfiddle.net/whLf02n8/

html:

<svg height="100" width="100">
  <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
</svg>

<button id="7">7</button>
<button id="3">3</button>

javascript:

$('button').click(function() {
    const id = $(this).attr('id');
  $('svg circle').attr('stroke-width', id);
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM