On Oct 16, 2007, at 12:24 PM, Andy Matthews wrote:

// creates a new, empty jQueru object
$(
        // create a new jQuery object using virtual-sensor
        // as the selector, with 'data' as the context
        // and it returns the ith record in that query into
        // an array.
        $("virtual-sensor",data).get(i)
// this gets all records that have an attribute of name
).attr("name");


A couple notes:
1. It looks like the selector is converting a jQuery object into a DOM element and then back into a jQuery object. Seems a little convoluted. I think the same thing can be achieved this way (assuming that "i" is coming from somewhere earlier in the script):

$('virtual-sensor:eq(' + i + ')', data).attr('name');

2. The attr('name') part is actually returning the value of the name attribute. It's not filtering the matched set of elements.

The problem is that this code will never work as written. The author is
trying to
Use 'virtual-sensor' as a selector, but in this setup, they're acting as if
it's an HTML tag, which it's not. It should be '.virtual-sensor' or
'#virtual-sensor'

Actually, if this is an XML file, it's quite possible that there is a <virtual-sensor> element.

--Karl


-----Original Message-----
From: [email protected] [mailto:jquery- [EMAIL PROTECTED] On
Behalf Of charliend
Sent: Tuesday, October 16, 2007 9:05 AM
To: jQuery (English)
Subject: [jQuery] Can't understand a Jquery statement


Hello all,

I'm beginning working on a project which has been writing using Jquery (I'm
novice) and I really can't understand that line:
$($("virtual-sensor",data).get(i)).attr("name");

Can you traduce it to me?
Thank you
Charlie



Reply via email to