투케이2K

70. (jquery/제이쿼리) jQuery.fx.speeds 프로퍼티 기본 값 설정 변경 실시 - fast , normal , slow 본문

Jquery

70. (jquery/제이쿼리) jQuery.fx.speeds 프로퍼티 기본 값 설정 변경 실시 - fast , normal , slow

투케이2K 2022. 12. 2. 14:33
반응형

[개발 환경 설정]

개발 툴 : Edit++

개발 언어 : jquery

 

[소스 코드]

    <!-- [CDN 라이브러리 설치] -->
    <script src="https://code.jquery.com/jquery-latest.min.js"></script>





    <!-- [내부 자바스크립트 J쿼리 이벤트 지정] -->
    <script>


        /**
         * --------------------------------
         * [요약 설명]
         * --------------------------------
         * 1. load : html 최초 로드 수행 시 호출 되는 함수입니다
         * --------------------------------
         * 2. on : jquery 에서 이벤트를 적용할 때 사용합니다
         * --------------------------------
         * 3. slideToggle : 특정 요소가 slide up 상태인 경우 >> slide down 처리 / slide down 인 경우 slide up 처리를 수행합니다
         * --------------------------------
         * 4. jQuery.fx.speeds.fast : jQuery.fx 객체의 speeds 프로퍼티의 fast 의 값을 설정 합니다
         * --------------------------------
        */



        // [html 최초 로드 및 이벤트 상시 대기 실시]
        $(window).load(function(){
            console.log("");
            console.log("=========================================");
            console.log("[window load] : [html 로드 수행 실시]");
            console.log("=========================================");
            console.log("");

            // [테스트 함수 호출]
            testMain();
        });



        // [테스트 자바스크립트 함수]
        function testMain(){
            console.log("");
            console.log("=========================================");
            console.log("[testMain] : [start]");
            console.log("=========================================");
            console.log(""); 

            // [fast = 0.2 / normal = 0.4 / slow = 0.6]
            // [jQuery.fx 객체의 speeds 프로퍼티의 fast 의 값을 1초로 커스텀 변경 함 >> 디폴트 속도는 0.2 초]
            jQuery.fx.speeds.fast = 1000;


            // [on 이벤트 적용 실시]
            $("#divTag").on("click", function() {

                // id 가 list 인 요소에 슬라이드 up / 슬라이드 down 적용 실시
                $("#list").slideToggle("fast");

            });

        };


    </script>
​

<body>

    <!-- [container 생성 실시] -->    
    <div id="divTag" class="divTagContentHeightSmallClass">
        <p id="pTag" class="pTagContentMiddleClass">테스트 버튼</p>
    </div>


    <!-- [리스트 선언 실시] -->
    <ul id="list">
        <li id="firstItem">1</li>
        <li>2</li>
        <li>3</li>
    </ul>


</body>
 

[결과 출력]


 

반응형
Comments