Two click functions where the second one is requiring an additional click to fire.
hello everyone,
I can not seem to understand why when the second div is clicked it is needing to be clicked a second time in order to run. Any help is greatly appreciated!
- $(document).ready(function(){
-
- var $moveOne = $('#three'),
- $moveTwo = $('#two');
-
- var r = 0,
- dir = true;
-
-
-
- $('.enable2').unbind().click(function(e) {
- if (e.target !==this)
- return;
- console.log('clicked');
- dir = !dir;
- r = dir? -625 : 0;
- $moveOne.stop().animate({right: r+'px'}, 400);
-
- });
- $('.enable1').unbind().click(function(f) {
- if (f.target !==this)
- return;
- console.log('clicked');
- dir = !dir;
- r = dir? -625 : 0;
- $moveTwo.stop().animate({right: r+'px'}, 400);
-
- });
- });