using npm:
npm install jquery-simple-txt-counter
import 'jquery-simple-txt-counter/jquery-simple-txt-counter';
or
<script src="jquery-simple-txt-counter/jquery-simple-txt-counter.js"></script>
and
$('textarea').simpleTxtCounter({
maxLength: 100,
countText: 'Maximum:',
countElem: '<div class="form-text"></div>',
lineBreak: false,
});
- With customized insert
<div class="btn-group">
<textarea maxlength="200"></textarea>
<button type="button">ADD</button>
</div>
$('textarea').simpleTxtCounter({
after: '.btn-group'
});
Option | Default | Description |
---|---|---|
after | undefined | selector to after inserting the counter element |
maxLength | undefined | Maximum size (maxlength attribute is used if it exists) |
countText | undefined | Pre text before counter |
countElem | <div/> |
Counter element |
lineBreak | true | If false , it does not allow line breakage |