Home Web Front-end JS Tutorial Detailed explanation of usage examples of stop() in jquery

Detailed explanation of usage examples of stop() in jquery

Jun 30, 2017 am 11:34 AM
jquery stop usage

stop is the method used in jQuery to control page animation effects. Immediately after running, end the animation effect on the current page.
stop has added two parameters in the new version of jQuery:
The first parameter means whether to clear the animation sequence, that is, whether to stop the animation effect of the current element or to stop all animation effects attached to it, usually false, skip the current animation effect and execute the next animation effect;
The second parameter is whether to execute the current animation effect to the end, which means that when stopping the current animation, the animation effect has just been executed. Normally, what you want at this time It is the effect after the animation is executed, then this parameter is true. Otherwise the animation effect will stop when stop is executed

HTML code

<p id="animater">
            stop()方法测试
        </p>

        <p id="button">
            <input type="button" id="button1" value="stop()"/>
            <input type="button" id="button2" value="stop(true)"/>
            <input type="button" id="button3" value="stop(false,true)"/>
            <input type="button" id="button4" value="stop(true,true)"/>
            
        </p>
Copy after login


CSS code

#animater{
                width: 150px;
                background:activeborder;
                border: 1px solid black;
                /*为了移动,需设置此属性*/
                position: relative;
            }
Copy after login


jquery code

//            为了看效果,随意写的动画
                $('#animater').animate({
                    'right':-800
                }, 3000).animate({'font-size':'16px'},'normal').animate({'font-size':'26px'},'normal').animate({'font-size':'36px'},'normal').animate({'font-size':'46px'},'normal').animate({'font-size':'56px'},'normal').animate({'opacity':0},'normal').animate({'opacity':1},'normal').animate({'left':200,'font-size':'16px'},'normal');



        
                //           点击不同的button执行不同的操作
        
                $('#button1').click(function(){
                    //默认参数是false,不管写一个false还是两个false还是没写false效果一样
                    $('#animater').stop();
                });
                $('#button2').click(function(){
                    //第二个参数默认false
                    $('#animater').stop(true);
                });
                $('#button3').click(function(){
                    $('#animater').stop(false,true);
                });
                $('#button4').click(function(){
                    $('#animater').stop(true,true);
                });
Copy after login

The above is the detailed content of Detailed explanation of usage examples of stop() in jquery. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery?

Detailed explanation and usage introduction of MySQL ISNULL function Detailed explanation and usage introduction of MySQL ISNULL function Mar 01, 2024 pm 05:24 PM

Detailed explanation and usage introduction of MySQL ISNULL function

How to remove the height attribute of an element with jQuery? How to remove the height attribute of an element with jQuery? Feb 28, 2024 am 08:39 AM

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

jQuery Tips: Quickly modify the text of all a tags on the page

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Use jQuery to modify the text content of all a tags

Correct usage of POST request in PHP Correct usage of POST request in PHP Mar 27, 2024 pm 03:15 PM

Correct usage of POST request in PHP

Understand the role and application scenarios of eq in jQuery Understand the role and application scenarios of eq in jQuery Feb 28, 2024 pm 01:15 PM

Understand the role and application scenarios of eq in jQuery

How to use sleep function? How to use sleep function? Mar 20, 2024 am 08:37 AM

How to use sleep function?

See all articles