메뉴 건너뛰기

조회 수 7420 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
index.html

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
    <head>
        <title>Input Counter</title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <link href="stylesheet.css" media="screen" rel="stylesheet" type="text/css" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
        <script src="application.js" type="text/javascript"></script>
    </head>
    <body>
        <div id="container">
            <form action="index.html" method="POST">
                <textarea></textarea>
                <span class="input-counter"></span>
                <input type="submit" id="input-submit" value="등록" />
            </form>
        </div>
    </body>
</html>


stylesheet.js

body {
    font-size: 12px;
    background: #FFF;
    color: #333;
    margin: 0;
}

#container {
    margin: 10px auto;
    width: 500px;
    padding: 10px;
    background: #CCC;
}

form {
    overflow: hidden;
    height: 100%;
}

textarea {
    display: block;
    width: 99%;
    height: 5.0em;
    margin-bottom: 0.5em;
}

span.input-counter {
    float: left;
    font-weight: bold;
    color: #000;
}

span.input-counter.disabled {
    color: #F00;
}

input#input-submit {
    float: right;
}


application.js

$(function() {
    var maxLength = 140;

    function updateInputCount() {
        var textLength = $('textarea').val().length;
        var count = maxLength - textLength;
        $('span.input-counter').text(count);
        if (count < 0) {
            $('span.input-counter').addClass('disabled');
            $('input#input-submit').prop('disabled', true);
        } else {
            $('span.input-counter').removeClass('disabled');
            $('input#input-submit').prop('disabled', false);
        }
    }

    $('textarea')
        .focus(updateInputCount)
        .blur(updateInputCount)
        .keypress(updateInputCount);
    window.setInterval(updateInputCount, 100);

    updateInputCount();
});

  1. No Image 19Jun
    by
    2015/06/19 Views 14619 

    공백 검사 함수

  2. 개발자도구 F12키 막기

  3. No Image 06Oct
    by
    2016/10/06 Views 12368 

    간단한 동적 SELECT 박스 구현하기

  4. No Image 11Sep
    by
    2016/09/11 Views 5879 

    간단하게 우클릭 막는방법

  5. [라디오버튼 오류 체크] 간단한 문제 예제

  6. No Image 22Dec
    by
    2016/12/22 Views 8375 

    [단축키 설정 자바스크립트]shortcut.js

  7. No Image 01Mar
    by
    2014/03/01 Views 6399 

    [jQuery] 탭 메뉴

  8. No Image 01Mar
    by
    2014/03/01 Views 12017 

    [jQuery] 실시간 검색어 순위 순서대로 보여주기

  9. No Image 01Mar
    by
    2014/03/01 Views 46027 

    [jQuery] 상위부터 차례로 지역 선택하기

  10. No Image 01Mar
    by 조쉬
    2014/03/01 Views 7420 

    [jQuery] textarea 글자수 카운트

  11. No Image 19Feb
    by
    2017/02/19 Views 8526 

    [INPUT BOX] 텍스트박스(INPUT 박스) 가 동적으로 추가,삭제됩니다

  12. No Image 26Mar
    by
    2021/03/26 Views 3560 

    utf-8일때 alert 한글 깨짐 해결

  13. top 부분이 고정되는 슬라이딩 메뉴입니다

  14. No Image 27Feb
    by
    2014/02/27 Views 6161 

    textarea의 글자수 제한

  15. No Image 01Mar
    by
    2014/03/01 Views 5651 

    Textarea 글자수 체크

  16. No Image 26Mar
    by
    2021/03/26 Views 204 

    split, join, replace, replace_all

  17. No Image 16Jan
    by
    2019/01/16 Views 1450 

    span - 동적으로 글자 바꾸기, 보이기 안보이기

  18. No Image 22Dec
    by
    2016/12/22 Views 8162 

    setTimeout() / clearTimeout() / setInterval()

  19. No Image 22Dec
    by
    2016/12/22 Views 6241 

    setTimeout 대체 스크립트 함수 (일시멈춤)

  20. No Image 04Jul
    by
    2018/07/04 Views 4014 

    SelectBox에서 선택된 항목의 텍스트, 값 가져오기 선택 옵션 넣기.

Board Pagination Prev 1 ... 3 4 5 6 7 8 9 10 11 12 13 Next
/ 13

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved