function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jennifer PratherJennifer Prather 

Input Rich Text Counter

I was trying to add a counter to an input rich text lightning web component. I can get it to display the character count but cannot get it to count down. I was getting an error saying the counter variable I called was not being used as well as the maxlength.
<template>
    <lightning-input-rich-text
        type="text" value={value} maxlength="100">
    </lightning-input-rich-text>
    <span id="counter">100</span>
</template>
 
/* eslint-disable no-unused-vars */
import { LightningElement, track, api } from 'lwc';

export default class InputRichText extends LightningElement {
    @api value;
    @track value;

    itemsChange(_oninput){
        let counter = this.getElementById("counter");
        let maxlength = this.getAttribute("maxlength");
        counter.textContent = maxlength - this.value.length;
    }
}