小编Dyl*_*lan的帖子

SVG:单击按钮后在 animateTransform 上触发单击事件

我想让我的 svg 动画在单击 html 按钮时运行。我想我可以通过begin="click在 my 中设置animateTransform然后触发点击事件来完成这项工作animateTransform(或包含 的 svg 元素animateTransform,我都尝试过)使用 js。任何建议都会有很大帮助。

var needle = $('#needle'),
  tape = $('#tape'),
  btn = $('#muhBtn');

btn.on('click', function() {
  needle.click();
  tape.click();
});
Run Code Online (Sandbox Code Playgroud)
#tape {
  fill: #ED1C24;
}

#needle {
  fill: #8DC63F;
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<?xml version="1.0" encoding="utf-8"?>

<svg version="1.1" id="Layer_1" xmlns:x="&ns_extend;" xmlns:i="&ns_ai;" xmlns:graph="&ns_graphs;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="200px" height="200px" viewBox="0 0 200 200" style="enable-background:new 0 0 200 200;"
  xml:space="preserve">
    <circle cx="100" cy="100" r="100" class="background"/>
    <path class="st0" id="tape" …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery svg smil

0
推荐指数
1
解决办法
5355
查看次数

标签 统计

html ×1

javascript ×1

jquery ×1

smil ×1

svg ×1