我想在每次单击按钮时切换/切换变量的值,以便
var ccw = $("#part1, #part3, #screw1, #screw3, #screw5, #part7");
变成
ccw = $("#part4, #part2, #screw2, #screw4");
和
cw = $("#part1, #part3, #screw1, #screw3, #screw5, #part7");
变成
cw = $("#part4, #part2, #screw2, #screw4");
我的代码
var angle;
var reverseAngle;
var angleCW;
var angleCCW;
var cw = $("#part1, #part3, #screw1, #screw3, #screw5, #part7");
var ccw = $("#part4, #part2, #screw2, #screw4");
function machine() {
angle = 0;
reverseAngle = 0;
$("#part10").unbind('click').click(function(e) {
$(this).toggle(function() {
});
ccw = $("#part1, #part3, #screw1, #screw3, #screw5, #part7");
cw = $("#part4, #part2, #screw2, #screw4");
$("#part10").hide();
$("#part11").show();
$("#part10").delay(800).fadeIn();
$("#part11").delay(800).fadeOut();
reverseRotation();
});
setInterval(function(){
reverseRotation();
cw.rotate(angleCW);
ccw.rotate(angleCCW);
$("#part9").animate({
opacity: "-=0.1",
top: "-=1"
}, 200 , function() {
if($("#part9").css("opacity") <= 0){
$(this).css({
opacity: '1',
top: '0'
});
}
});
},50);
}