我下载了一个JS示例,我想问你是否有机会开始加载窗口。
<script>
window.onload = function() {
$.fn.rotate.serialize();
var gear1 = document.getElementById('gear1');
var gear2 = document.getElementById('gear2');
$('#centerpiece').on('mouseenter',function() {
if(!gear1.isRotating && !gear2.isRotating) {
gear1.isRotating = true;
gear2.isRotating = true;
$(gear1).rotate(360,{speed:140},function() {
gear1.isRotating = true;
$(this).rotate('reset');
});
$(gear2).rotate(360,{speed:110},function() {
gear2.isRotating = true;
$(this).rotate('reset');
});
}
});
};
</script>
答案 0 :(得分:0)
删除了window.onload,现在无需鼠标悬停即可运行。
if(!gear1.isRotating && !gear2.isRotating) {
gear1.isRotating = true;
gear2.isRotating = true;
$('#gear1').rotate(360,{speed:140},function() {
gear1.isRotating = true;
$('#gear1').rotate('reset');
});
$('#gear2').rotate(360,{speed:110},function() {
gear2.isRotating = true;
$('#gear2').rotate('reset');
});
}