본문 바로가기

Web/javascript & jQuery

textarea 글자 수 표시하기

반응형
$(document).ready(function(){
 document.oncontextmenu = new Function('return false');
 document.ondragstart = new Function('return false');
 document.onselectstart = new Function('return false');


 $(function() {function updateInputCount() {
  var textLength = $('textarea').val().length;
  var count = textLength;
  $('span.input-counter1').text(count);
  if (count >= 250) {
   $('span.inputCnt').addClass('disabled');
  } else {
   $('span.inputCnt').removeClass('disabled');
  }
 }

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

0/250

 

 

 

 

반응형