简体   繁体   中英

Continuous Jquery rotation transfer?

I have two buttons which are located on opposite sides of a form ("Next" on front, "Submit" on back). The buttons perform the rotation (180deg) correctly, however, they only work for one click each. In other words, the onClick command only works once per click. Is there any way for me to reset my transformation in order repeat my rotation on click infinitely?

 <script type="text/javascript"> $(document).ready(function() { $("input[name='next']").on("click", function() { // console.log( "The NEXT Button Worked!" ); $(".form").css("transform", "rotateY(180deg)"); }) $("input[name='back']").on("click", function() { // console.log( "The BACK Button Worked!" ); $(".formFlipAgain").css("transform", "rotateY(180deg)"); }) }); function showBack() { setTimeout(function() { document.getElementById("backSide").style.display = "block"; }, 600); setTimeout(function() { document.getElementById("frontSide").style.display = "none"; }, 600); }; function showFront() { setTimeout(function() { document.getElementById("frontSide").style.display = "block"; }, 600); setTimeout(function() { document.getElementById("backSide").style.display = "none"; }, 600); }; 

Introduce two flags.

var flag1=0;
var flag2=0
$(document).ready(function() {
  $("input[name='next']").on("click", function() {
    // console.log( "The NEXT Button Worked!" );
    $(".form").css("transform", "rotateY("+flag1?0:180+"deg)");
    flag1=!flag1;
  })
  $("input[name='back']").on("click", function() {
    // console.log( "The BACK Button Worked!" );
    $(".formFlipAgain").css("transform", "rotateY("+flag2?0:180+"deg)");
    flag2=!flag2;
  })
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM