Reputation: 3
I tried to do an event listener, in my case with "keyup" to count the entered elements.
Everything works when I link the message-box with its ID, like so:
$("#message-box-1").on("keyup", function() {...
but when I link the class, like so:
$(".message-box").on("keyup", function() {...
the counter doesn't work anymore.
I had a similar problem before where I had to use the ID instead of the class, because otherwise the function wouldn't work...
Upvotes: 0
Views: 73
Reputation: 26342
you have two classes
<textarea style="resize:none" cols="40" rows="5" class="form-control" class="message-box" id="message-box-1" title="Please enter a message" required="required" placeholder="Your message here"></textarea>
please remove as jquery will ignore second attribute with same name or merge with same class attribute
<textarea style="resize:none" cols="40" rows="5" class="form-control message-box" id="message-box-1" title="Please enter a message" required="required" placeholder="Your message here"></textarea>
Upvotes: 2