最佳答案
我抓取了一个 jQuery 对象数组,然后通过. each ()修改数组中的每个 jQuery。
在本例中,我更新了类名,以触发一个-webkit-shift-property,从而利用一个 css 转换。
我想有一个暂停之前,每个 CSS 过渡开始。我正在使用以下内容,但是每次更新之间没有延迟。相反,它们似乎都在同时更新。
function positionCards() {
$cards = $('#gameboard .card');
$cards.each(function() {
setTimeout( function(){ addPositioningClass($(this)); }, 500 )
});
}
function addPositioningClasses($card){
$card
.addClass('position')
}
我希望 setTimeout 能够解决这个问题,但是它似乎不起作用。是否有办法在每个对象的每个 CLASS 名称更新之前完成暂停?