[英]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.