Hi bart, let me cite from the spec:

"get(): Access all matched DOM elements. This serves as a backwards-
compatible way of accessing all matched elements (other than the
jQuery object itself, which is, in fact, an array of elements). It is
useful if you need to operate on the DOM elements themselves instead
of using built-in jQuery functions."

.get() returns DOM elements not a jQuery object where all the magic
stuff happens. To match the first element in a jQuery you need to do:

// either this
$('p.fl').eq(0).css('background','red');
// or this
$('p.fl').slice(0,1).css('background','red');
// or this
$('p.fl:first').css('background','red');

There's a couple of other ways to do that but I guess this is enough.
--
Bohdan

On Jan 30, 5:31 pm, bart <b...@ivwd.nl> wrote:
> Somehow I don't get the concept of get() right. The following
> expression gives an error;
>
> $('p.fl').get(0).css('background', 'red');
>
> Now what I'm trying to do here is select the first paragraph from all
> the paragraphs with a class of "fl". After that I'm just trying to get
> a visual id by making it red but it's more about grabbing the element
> really. There's probably a very good reason why this doesn't work but
> what I understand from documentation this should work?
>
> This ultimate goal is to hide a paragraph based on it's index. This
> index is gotten from a clicked link. So far I've got this, but it's
> stuck on the get() part.
>
> $('a.leesmeer').click(function()
> {
>         var nmbr = $('a.leesmeer').index(this);
>         $('p.fl').get(nmbr).hide();
>         $('div.case').get(nmbr).show();
>         return false;
>
> });

Reply via email to