I've been working on a code snippet for a template module that I have been creating and I've hit a wall so to speak. I'm trying to loop through all textareas on my page, and apply formatting with some very basic validation.
Javascript is not my strongest suit but I can understand it to a point, my question is how do I collect the ID's and then use them to apply the formatting.
For example,
for each (textarea)
{
collect character restriction from html
display character restriction in a formatted manner
}
I have included my JSFiddle which I have been using to build this snippet.
getAttribute('id')to get the id of the object: jsfiddle.net/grhLupp7/2. However, you're already collecting all the textareas incount. Just access them viacount[i]el.id<- This is shortestiis the index,count[i]is the textarea. Have a look at linked fiddle, I've put in a line thatconsole.logs retrieval of id. And as @TheProHands pointed out you can usecount[i].idto retrieve id as well