javascript - 如何使用css或js选择animation-iteration-count的值?

标签 javascript css

如何使用 js 或 css 选择 animation-iteration-count 的值?下面是我的CSS。目的是第一次画黑色,第二次画。感谢您的帮助。

.path { animation: draw 8.5s linear ; } @keyframes draw { 0% {stroke: #000;} 25% {stroke:#000;} 50% {stroke: #000;} 75% {stroke: #000;} 100% {stroke: none;fill:#000;stroke-dashoffset:100; } }

最佳答案

我可以使用下面的 jQuery 函数。

 function animate(count) {
            console.log("animate", count)

            if (count == 0) {
                $('.path').css({
                    'animation': 'draw2 4s'
                });

            }

            if (count == 1) {
                $('.path').css({
                    'animation': 'draw1 4s'
                });
            }
            if (count == 2) {
                $('.path').css({
                    'animation': 'draw3 4s'
                });
            }
            if (count > 0) $('.path:first').one("animationend", function () {
                animate(count - 1)
            })
        }

关于javascript - 如何使用css或js选择animation-iteration-count的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51706984/

相关文章:

javascript - .each 不在 jquery 中工作

CSS 左右对齐文本

html - 我们如何修复 iphone 设备上的自定义表格 ui?

css - Divs 在调整大小时彼此重叠(HTML CSS)

javascript - 通过父 div 到祖 parent div 背景的 div 透明

javascript - 无法使 javascript "show hide"div 代码正常工作

javascript - 如何将自定义事件添加到 Node 中的类中?

javascript - 使用 jquery 创建和删除 DOM 的对象避免内存泄漏

javascript - TestCafe:如果用户从另一台计算机登录,如何测试注销

javascript - 隐藏/禁用 <div> 和 <a> onlick of and image 但当它回到原始状态时恢复它们