1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

inputの文字数をカウント・表示する

1
Last updated at Posted at 2020-05-12

やりたいこと

  • input欄に入力されている文字数をリアルタイムでカウント・表示したい。

実装

まずはHTML

<input id="question"></input>
<p><span id="numberOfLetter"></span></p>

次にjQuery

$(function(){
  $('#question').keyup(function() {
    let count = $(this).val().length;
    $('#numberOfLetter').text(count);    
  });
});

これで、input欄の下に、入力文字数を表示することができました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?