> $(".highlight").removeClass;
The selector $('.highlight') is choosing all your objects that have
the class 'highligh'. removeClass still needs to know what class to
remove (ie, the method removeClass doesn't know how or why you
selected those particular elements). It takes the class name as an
argument, so to remove 'highlight' from everything that has the class
'highlight' you do this:
$('.highlight').removeCalss('highlight');
> $("this:even").addClass("shaded");
Note that 'this' is within quotation marks, so you're not actually
using the 'this' keyword. What $('this:even') means is: "Find every
even object of type 'this'". Of course, in html there is no 'this'
element.
To use it correctly, you'd use it like this: $(this) - note there are
no quotes. Think of it as referring to the 'subject' of a particular
function.
Eg, in the following piece of code:
$('#someDiv).click(function(){
$(this).hide();
});
$(this) refers to the the object that was clicked.
Eg2, in the following code:
$('h1').each(function(){
$(this).css('color': 'red');
});
$(this) refers to the particular 'h1' element that is being iterated
over.
Using ':even' narrows a selection of objects to only even ones. You
don't use it with 'this' (it doesn't really mean anything in that
context), but, for example you can do:
$('div:even').hide();
This would hide every second div element.
Hope this helps.
Hamish
On Apr 11, 2:23 pm, Jeff <[EMAIL PROTECTED]> wrote:
> 'scuse me for the noob question here...
>
> i have statements like this:
>
> $(".highlight").removeClass;
> $("this:even").addClass("shaded");
>
> And I don't think I'm using "this" or :even correctly; it doesn't work
> =)
>
> Googling has turned up some different ways that the "this" keyword is
> used, and I'm not sure what is right here. I'm just trying to remove a
> class from a bunch of elements and then apply a new class to even
> numbered elements.
>
> Any ideas? Again, sorry for the dumb question, but googling the word
> "this" isn't very helpful since you get like 10 kabillion results.