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();
});
게시글 목록
| 번호 | 제목 |
|---|---|
| 12463 |
JavaScript
이미지 좌우로 이동 갤러리 입니다.
|
| 12462 | |
| 12461 |
JavaScript
쉬운 replaceAll 입니다.
|
| 12460 | |
| 12459 | |
| 12458 | |
| 12457 | |
| 12456 |
JavaScript
콤보스타일 메뉴 입니다.
|
| 12455 |
JavaScript
쿠키를 이용한 레이어 공지창 입니다.
|
| 12454 |
JavaScript
효과있는 텍스트 틱커 입니다.
|
| 12453 | |
| 12452 |
PHP
HTTP 인증 하기 입니다.
|
| 12451 |
JavaScript
외부 문서 불러오기 입니다.
|
| 12450 |
JavaScript
지정한 날짜까지 New 이미지를 띄워주기 입니다.
|
| 12449 | |
| 12448 |
JavaScript
메일 주소 검사하기 체크박스 입니다.
|
| 12447 |
JavaScript
무단링크 금지하기 입니다.
|
| 12446 | |
| 12445 |
MySQL
DB백업 및 복원
|
| 12444 |
JavaScript
페이지가 다른 사이트의 프레임에 갇히는 것을 막기 입니다.
|
| 12443 | |
| 12442 | |
| 12441 |
jQuery
input text 대문자만 받는 Jquery
|
| 12440 | |
| 12439 |
JavaScript
이미지 업로드와 미리보기 입니다.
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기