jQuery stop effect when button is pressed

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>stop demo</title>
  <style>
  div {
    position: absolute;
    background-color: #abc;
    left: 0px;
    top: 30px;
    width: 60px;
    height: 60px;
    margin: 5px;
  }
  </style>
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
 
<button id="go">Go</button>
<button id="stop">STOP!</button>
<button id="back">Back</button>
<div class="block"></div>
 
<script>
// Start animation
$( "#go" ).click(function() {
  $( ".block" ).animate({ left: "+=100px" }, 2000 );
});
 
// Stop animation when button is clicked
$( "#stop" ).click(function() {
  $( ".block" ).stop();
});
 
// Start animation in the opposite direction
$( "#back" ).click(function() {
  $( ".block" ).animate({ left: "-=100px" }, 2000 );
});
</script>
 
</body>
</html>

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
jQuery stop effect when button is pressed .stop() jquery jQuery stop all jquery .stio stop callback jquery jquery animatation inturrupting previous animation stop other instances of jquery stop animation in j query stop animation jquery stop animation immediately on clicking jquery animation left and when click stop display value click to play and automatic stop jquery jquery stop after 3 can i use stop(toggel) on jquery jquery stop( jquery stop( false true) differences stop animation in jquery stop animate jquery stop function jquery dpo animation inifnite jquery animate stop animation stop() documentation cancel all jquery animations on new action stop current animation on new jquery stop current animation on new js stop jquery STOP SENDING ME JQUERT CODE stop animation without plugin + jquery stop adding value in jquery jquery stop animation on element how to stop and start internal animation with a button stop all animations on click javascript jquery stop animation jquery .stop method run one div stop another in html jQeury .stop() jquery .stop() jquery cancel stop function jquery stop toggeling for time jquery stop animation after complete jquery animate for a time limit and stop automaticaly jquery end animate after timer jquery stop animate jquery stop jquery stop animate after last click jquery after all animation stop .stop() how to stop anime in jquery jquery cancel animation queue jquery cancel animation jquery stop() stop to next process in jquery stop class from being removed by ajax jquery stop class from being removed by ajaxjquery jQuery function which can stop the animation of the above effect whilst in progress. a jQuery function which can stop the animation anime stop jquery .stop jquery how to stop animate in jquery stop(true,true) jquery jquery .stop jquery interrupt stopping element jquery
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source