Aravindhan
Aravindhan

Reputation: 3626

character counting not works for the dynamically created elements

I am using charcount.js to count the number of characters entered in the textarea..

    <textarea class="counter" rows="3"></textarea>

in jquery i called it as

    $('.counter').charCount();

it works for me...when i created the textarea in the javascript dynamically it does not works

    var txtar=document.createElement("textarea");
    txtar.setAttribute("maxlength","140");
    txtar.setAttribute("class","counter");
    ad.appendChild(txtar);

the textarea correctly added into the document but the charcount function not works .....

how can i resolve this

thanks in advance

Upvotes: 0

Views: 94

Answers (1)

David Hedlund
David Hedlund

Reputation: 129812

Are you calling charCount() after the element has been appended to the DOM? You should be.

Upvotes: 1

Related Questions