Javascript一次对两种效果进行样式化
javascript styling two effects at once
你好,我有一堆动态创建的div框与iddiv1-div999。然后我抓取随机的盒子,并将动画名称更改为"grow"。我还想将播放状态更改为"running",但现在我只是随机选择另一组来更改播放状态。
else if (e.keyCode == '40') {
for(var i = 0;i <400; i++){
document.getElementById("div"+Math.floor((Math.random()*1000) + 1 )).style.animationName = "Grow";
document.getElementById("div"+Math.floor((Math.random()*1000) + 1 )).style.animationPlayState = "running";
}
}
我想更改一个组选择的动画名称和播放状态。比如:
document.getElementById("div"+Math.floor((Math.random()*1000) + 1 )).style.animationName = "Grow" / style.animationPlayState = "running";
有什么办法可以做到吗?
谢谢!
如何将div ID的随机组存储在数组中?希望对你有帮助。
else if (e.keyCode == '40') {
for(var i = 0;i <400; i++){
var randomSelection=[]; //a new array to store all ID's
randomSelection[i]=Math.floor((Math.random()*1000) + 1))
document.getElementById("div"+randomSelection[i].style.animationName = "Grow";
document.getElementById("div"+randomSelection[i].style.animationPlayState = "running";
}
}
相关文章:
- 使用javascript单击同一按钮,在两种样式之间更改css值
- 把两种不同的形式合为一
- 这两种不同的创建对象文字的方法有什么区别
- angularjs两种功能的替代品(欧芹和重置)
- 我想要相同的函数以两种方式反应
- HTML中两种JS实现之间的差异
- 比较两种不同格式的时间戳-GAS
- 这两种方法有什么不同
- 正则表达式,两种方式,不同的结果
- 如何将两种不同类型的事件附加到同一元素
- 这两种使用 jQuery 追加 DOM 元素的方法有什么不同
- 通过两种方法创建和更新 CSS
- 什么'这两种继承策略之间的区别是什么
- 在 OpenLayers 3 中的单个点上设置两种样式
- javascript中一个按钮样式的两种字体类型
- 如何设置角度谷歌折线图的样式,使其在同一条线上有两种样式
- 设置默认值的两种样式
- Javascript一次对两种效果进行样式化
- Javascript可以在一个元素的两种不同的CSS样式之间切换
- 是否可以在画布的同一路径上使用两种不同的笔触样式?