Little confusion here indeed : jQuery wraps selected elements in a "magic
array" that keep them warm and ready to respond to any jQuery method, so
when you query $(this).length you're asking for jQuery's "magic array"'s
length, which is 1 (1 element inside).

If you want to get the length of the string inside the element, use .val()
to get the element's value :
$(this).val().length

This should do the trick.

Regards.

Michel Belleville


2009/11/24 rjc <r.jerome.cousin...@gmail.com>

>
> Hi, i'm updating a div with the length of a textarea.
>
> <script type="text/javascript">
> $().ready(function(){
>        $("#formElement_profileTeamProfile").keyup(function() {
>
>                var newText = $(this).length;
>                $('#countCharTeamProfile').html(newText);
>
>        });
> });
> </script>
>
> Every time i enter a char into the textarea, the value stays at 1.
> :confused:
>
> I am very new to any jQuery, i've been searching with no luck for hours!
>
> any help would be greatly appreciated!
>
> J.
> --
> View this message in context:
> http://old.nabble.com/update-div-with-textarea-length-tp26492474s27240p26492474.html
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.
>
>

Reply via email to