以下是我目前的代码:
var divArray = ["test", "love"]
var delayArray = ["delaya", "delayb", "delayc", "delayd", "delaye", "delayf", "delayg", "delayh", "delayi", "delayj", "delayk", "delayl", "delaym", "delaya", "delayb", "delayc", "delayd", "delaye", "delayf", "delayg", "delayh", "delayi", "delayj", "delayk", "delayl", "delaym"];
function zip(a, b, f) {
for(var i=0; i < a.length; i++){
f(a[i], b[i]);
};
}
function phase(){
var divGroup = this.children();
for(var i=0; i < divGroup.length; i++){
this.children()[i].className = 'wave ' + delayArray[Math.floor(Math.random()*26)];
}
}
for(var i = 0; i < divArray.length; i++) {
document.getElementById(divArray[i]).addEventListener('animationend', phase, false);
}
zip(divArray, delayArray, function(x, y) {
document.getElementById(x).className = 'transtart burn ' + y;
});
这是我想要完成的事情:http://jsfiddle.net/ACLM6/1/
我非常希望将两个新类添加到animationend
触发的元素的子元素中。但是我不确定我是否在phase()
中正确地调用元素子元素。
答案 0 :(得分:1)
不,你应该调用它:$(this).children()
- jQuery方法,
或this.children
- DOM节点属性。