我正在将CSS转换应用于元素.
target.style.transition = "color 10000ms ease";
target.style.color = "red";
在某些情况下,我希望立即达到此转换的结束状态,而无需等待转换完成.
如果我试试
target.style.transition = "color 0ms";
target.style.color = "red";
目前的转型只是继续.
干
target.style.transition = "color 0ms";
target.style.color = "blue";
立即将其设置为“蓝色”,而
target.style.transition = "color 0ms";
target.style.color = "blue";
target.style.color = "red";
导致过渡的继续. (在Chrome和FF中都尝试过)
有没有办法阻止过渡?
最佳答案 要立即停止转换并达到结束状态,请使用
target.style.transition = "none";
见DEMO.