메뉴 건너뛰기

조회 수 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 19Feb
    by
    2017/02/19 Views 8526 

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

  2. Location 객체 - URL 파싱 - URL에서 전달인자 추출하기 함수 작성

  3. No Image 03Feb
    by
    2015/02/03 Views 8500 

    페이지 로드 할때 컨트롤에 포커스 주기

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

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

  5. No Image 06Apr
    by
    2015/04/06 Views 8205 

    2단계 트리메뉴 마우스오버(mouseover), 온포커스(onfocus) 구현

  6. 드롭다운 메뉴를 만들어보자! -1탄

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

    setTimeout() / clearTimeout() / setInterval()

  8. No Image 17Nov
    by
    2016/11/17 Views 7928 

    브라우저별 이미지 크기 변경

  9. No Image 22Dec
    by
    2016/12/22 Views 7912 

    복사방지+드래그금지+마우스우클릭 금지

  10. No Image 19Jun
    by
    2015/06/19 Views 7876 

    정규식을 이용한 실시간 콤마(comma) 넣기

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

  12. No Image 03Feb
    by
    2015/02/03 Views 7673 

    양력-음력

  13. No Image 27Feb
    by
    2014/02/27 Views 7551 

    날짜 간의 일수 계산

  14. 'checkbox', 체크박스 모두체크 그리고 모두해제!

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

    체크박스 체크하면 레이어 보여주기. 체크안하면 알려주기

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

    [jQuery] textarea 글자수 카운트

  17. No Image 22Dec
    by
    2016/12/22 Views 7358 

    response.setHeader

  18. 'blur', 이미지 클릭시 테두리를 없애자!

  19. 'opener', 부모창과 자식창의 텍스트를 교환하자!

  20. 창에 대한 정보얻기 (창 크기, 창 위치)

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

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved