Comparing two values of CCS.left property via jquery


#1

Hey, guys! I tried to declare two variables with position.left.values in it, but when I compared them, nothing happened. I want to make an alert when position.left of two elements being moved (via .anim()) would become equal. Any suggestions, please?

$(document).ready(function() {
  var shuraLocation = 0;
  var pacanLocation = 0;
  animateDiv();
  $(document).keydown(function(key) {
    switch (parseInt(key.which, 10)) {
      case 39:
        $(".ye").animate({
          left: "+=10px"
        }, 'fast');
        break;
    }
  });
});

function animateDiv() {
  shuraLocation = $(".a").css("left");
  pacanLocation = $(".ye").css("left");
  if (shuraLocation === pacanLocation) {
    alert("8 ЛЕТ СТРОГАЧА ТЕБЯ НАСТИГЛИ");
  } else {
    $('.a').animate({
      left: "+=30px"
    }, function() {
      animateDiv();
    });
  };
};


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.