Excellent. And you're right. Straight from DOM :) Thanks very much for
taking the time. I see where I was going wrong.
Nate Cavanaugh wrote:
>
> *EDIT*
> I have a feeling you're either coming from Prototype, or straight from DOM
> scripting. I had the same preconceived notions when I first started with
> jQuery...
>
> So here is my attempt to do what you're trying to do (and from my testing,
> it all works :))
>
> $('#test textarea').each(function(){
> //this refers to the current element
> $(this).before('Current length:
> <span>'+this.value.length+'</span> characters')
> }) // Does NOT return the newly created item, but is still on the textarea
> .keyup(function(){
> //this refers to the current element
> var max_length = this.id.split('_')[1];
> var length_color = this.value.length > max_length ? 'red' : 'green';
> var current_length = this.value.length || 0;
> $(this).prev().html(current_length).css({color:length_color});
> });
>
>
--
View this message in context:
http://www.nabble.com/What-tools-should-I-use-to-troubleshoot-jquery-problems--%28John-Resig%2C-jquery-team%2C-other-gurus-please-share-your-tricks...%29-tf3066235.html#a8550204
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/