Reputation: 2097
I am using the real simple wysiwyg editor SCEditor for my website.
I am wandering how exactly I can get the current amount of characters in it's textarea and then output them below it?
I asked on the github but it seems not many people use it and the answer didn't make much sense to me, can someone clear it up for me?
The person replied with this:
var numOfCharacters = $textArea.data("sceditor").val().length;
Where: "$textArea" is a variable with a reference for the textarea DOM element wrapped in a jQuery object.
I have no idea what that means but I'm sure some of you will.
I want to output the length just to some text below the textarea.
Upvotes: 0
Views: 638
Reputation: 6162
you need learn something about jQuery.data . jQuery.data Store arbitrary data associated with the specified element. read more
jQuery plugins like SCeditor write their associated datas in jQuery.data of element.
for accessing this datas and management, they set their name (like 'sceditor') to it.
when you call $textArea.data("sceditor")
jQuery return datas that sceditior stored in element for you.
when you call $textArea.data("sceditor").val().length
you are requesting to get val(). it is text of current editor page for $textArea element and length return length of it's text.
Upvotes: 2