jquery - Stop animation loop -


How do I stop animation loops on click in jQuery? The following code generates an eyelid effect on the input field and works fine:

  function blink () {$ ('# client_name'). ({"Border-color": "# 00DB00"}, 400); $ ('# Client_name') Chetan ({"border-color": "#ccc"}, 400); } SetInterval (nap, 1000);  

I tried stop () but it only prevents the current running animation, not the full loop:

  $ ('# Client_surname'). Click (function () {$ ('# client_name'). Stop ();});  

You should use.

IntervalId, a unique interval id that you can pass to clear the interval ()

  var interval = set interval (blink, 1000); $ ('# Client_surname'). Click (function () {clear interval (interval);});  

Comments