【发布时间】:2020-07-09 14:02:12
【问题描述】:
这是我一直在使用的 javascript 代码。 我不断收到错误
'''
cannot set property 'animationplaystate' of undefined.
'''
'''
window.setTimeout(function time(){
var run=document.getElementsByClassName('logo');
run.style.animationplaystate='paused';
}, 3000);
'''
下面是元素的样式
'''
.logo{
color: rgb(0, 158, 150);
float:right;
padding-right:0px;
font-weight: 600;
padding-top:5px;
margin-right: 20px;
font-size: 2em;
padding-left: 30px;
animation-name:logo;
animation-duration: 1.5s;
animation-play-state: running;
}
'''
【问题讨论】:
-
这段代码是在标签下面还是在标签上面?我问你的代码在实际呈现标记之前运行的原因,使用 jQuery 文档就绪事件并设置 CSS
-
这些是单独文件中的两个单独代码
-
没关系,如果你在
<body>标签的末尾包含<script>标签,那么它将被最后渲染,如果你使用jQuery,它会在完整文档时触发一个函数已准备好进行编程 -
无论如何,我在下面给出了答案,我希望它应该工作
标签: javascript html css animation settimeout