如何onclick使用JavaScript 更改HTML元素的类以响应事件?
我认为这是最新Chrome(21.0.1180.57)中的一个错误,但我想我会在这里发帖只是为了仔细检查.
我正在使用javascript更改元素的旋转,并使用webkit过渡来为旋转设置动画.有时,根据开始和结束旋转,元素随着旋转随机缩放.我在这里做了一个演示:http://jsfiddle.net/XCwUQ/(点击正文).
有谁知道为什么会发生这种情况?
干杯,
基督教
我希望顺利转换css属性然后我想立即更改css属性值然后我想再次附加转换.为了更好地理解,请参阅以下示例:
if ($(".marquee").height() < $(".marquee-content").outerHeight(true)) {
$(".marquee-content").clone().appendTo($(".marquee-wrapper"));
}
$('.marquee-wrapper').css("transition", "transform 3s linear");
$('.marquee-wrapper').css("transform", "translateY(-" + $(".marquee-content").outerHeight(true) + "px)");
setInterval(function() {
$('.marquee-wrapper').css("transition", "none");
$('.marquee-wrapper').css("transform", "translateY(100px)"); //This should Immediately change translateY to 100px without smooth transition. But this doesn't happen without adding a delay before the below written line
// Its weird why javascript engine executes the below line before executing this line
$('.marquee-wrapper').css("transition", "transform 3s linear");
$('.marquee-wrapper').css("transform", "translateY(-" + $(".marquee-content").outerHeight(true) + "px)");
}, 3000);Run Code Online (Sandbox Code Playgroud)
.marquee {
margin: auto;
width: 600px;
height: …Run Code Online (Sandbox Code Playgroud)