javascript - Query animate() doesnt working -
i have following code:
var ison = false; $('.switch').on("click",function(){ if (ison){ $('.toggle').animate({ left:"18px" },10,"linear", { complete: function(){ $('#label').text("on"); } }); ison = false; } else { $('.toggle').animate({ left:"4px" }, 10,"linear", { complete: function(){ $('#label').text("off"); } }); ison = true; } });
http://codepen.io/pietrofxq/pen/lpzde?editors=001
it switch on/off made jquery
. working without animate()
method.
doing animation css, buggy in internet explorer.
here original effect: http://codepen.io/anon/pen/iwatp
why complete function in first link isn't working?
edit: code working still doesnt work on ie
you seem mixing the two different signatures of .animate
function. if pass duration , easing directly arguments, have same callback function:
$('.toggle').animate({left: "18px"}, 10, "linear", function(){ $('#label').text("on"); });
or have pass 2 objects:
$('.toggle').animate( { left:"18px" }, { duration: 10, easing: "linear", complete: function(){ $('#label').text("on"); } } );
Comments
Post a Comment