ここで何かを見落としているのではないかと思います。<span>
の下の要素にテキストエリアの文字数を表示したいと思います<textarea>
。私は次のjQueryとHTMLを使用しています:
jQuery:
$('#ws3 .textarea textarea[name="company-description"]').keyUp(function() {
var charLength = $(this).val().length;
$('span#charCount').html(charLength + ' of 250 characters used');
if($(this).val().length > 250)
$('span#charCount').html('<strong>You may only have up to 250 characters.</strong>');
});
HTML:
<div id="ws3" class="ws-section">
<label for="company-description">Describe your company for us</label>
<div class="textarea">
<textarea id="company-description" name="company-description" class="ws-required"></textarea>
</div>
<span id="charCount">charCount</span>
</div>
また、このブロックに続くすべてのjQueryコードは、ブラウザがこのコードブロックで.jsファイルの読み取りを停止したかのように機能しません。