inside every object's function there is a this... it all depends on
which object has the function!

inside an each function this is each element from the query
inside a plug-in this is the jquery object that has an array of elements.

most jq selectors keep a chain going so you have just what you started
with... some change the change so you have more or less elements, but
the chain continues, and you still have a jq object.

Why a class instead of an ID... I used the class like I would use a
local variable... since I can use prev() to find prior siblings and I
just want this one special one, I can code prev('span.special") to get
to the freshly added item.

SURE you can do the colors with a class too! you can change the class
or use the additive ability of classes to keep each part of the class
separate!


oops... I meant the id of the textarea.. not the form.

On 1/23/07, Daemach <[EMAIL PROTECTED]> wrote:
>
> This or that...This or that...
> http://bboyflexi.imeem.com/music/j-_J-4tV/the_choice_is_yours/ The choice is
> yours!
>
> Is there a list of rules somewhere that define where this is that or the
> reverse?  Or a very detailed description of what you're left with after a
> selector is run and the object is passed to the next link in the chain?
> It's apparently arcane knowledge :)  I see that in the keypress you have
> function (e) - where does e come from and how does it get passed?
>
> Much thanks for taking the time - great example and I *think* I get it.  The
> only things I'm not understanding are why you used #test as the first
> selector, since that is the form ID, and why the before statement was added
> last - or does that matter?
>
> And why would you use a class as an identifier?  it might be best to change
> the class to turn the text red/green rather than changing style elements.
> You might want to make the text bold too, for example.  I'm not opposed to
> it, just trying to understand the thought process.  Would changing the class
> break that selector?
>
>
> Ⓙⓐⓚⓔ wrote:
> >
> > this is not this! this is that!
> >
> > this is very much dependent on where this is used. inside an .each(),
> > this is an element.
> > inside a plugin this is a jquery object (& an array of elements).
> >
> > the this you used is weird on one, it is probably a null jquery object
> > with no elements... but I've never poked in to look!
> >
> > as far as debugging... everyone with firefox debugs with firebug...
> > some use others... and Internet Explorer users often flip over to
> > firefox for better debugging!
> >
> >        $('#test :textarea').before('Current length:&nbsp;<span id="'+
> > this.id
> > +'_len">'+this.value.length+'</span>&nbsp;characters').keypress(
> > function()
> > {
> >                $('#'+this.id + '_len').css('color', ((this.value.length >
> > parseInt(this.id.split()[1]))?'red':'green')).html(this.value.length)
> >        } );
> >
> > might be better as
> > $('#test').bind('keypress',function(e){
> >      // do your dirty work with this, the textarea
> >    $(this).prev('span.count').html(this.value.length)
> >     //  ...
> >
> > }).before('<span>Current length</span><span
> > class="count">0</span><span> chars</>'
> >
> >
> > All with no extra IDs!
> >
> > On 1/23/07, Daemach <[EMAIL PROTECTED]> wrote:
> >>
> >> I'm trying to sort out a problem with a selector and I'm not having much
> >> luck.  I'm using firebug at the moment, but I'm not able to easily see
> >> what
> >> the selector is picking up, if anything.  The first selector is here:
> >>
> >> $('#test :textarea').before('Current length:&nbsp;<span id="'+ this.id
> >> +'_len">'+this.value.length+'</span>&nbsp;characters')
> >>
> >> <form action="boo" name="test" id="test">
> >>         <textarea cols="54" rows="5" id="Desc_512"
> >> name="Description">SPORK</textarea>
> >> </form>
> >>
> >> _______________________________________________
> >> jQuery mailing list
> >> discuss@jquery.com
> >> http://jquery.com/discuss/
> >>
> >
> >
> > --
> > Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
> > _______________________________________________
> > jQuery mailing list
> > discuss@jquery.com
> > http://jquery.com/discuss/
> >
> >
>
> --
> 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#a8549419
> Sent from the JQuery mailing list archive at Nabble.com.
>
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>


-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to