I found out I can do:

var data = {};
data.x = {
        a: [],
        b: [],
        c: [],
        d: [],
        e: []
}

data.x.a.push({
        name: "foo",
        num: 0
});



data.x.a.push({
        name: "foo2",
        num: 0
});

$(data.x.a).filter('[num=0]')
or
$(data.x.a).filter('[name="foo2"]')

This does what I require.

On Dec 22, 10:05 pm, Ryura <yoyobo...@gmail.com> wrote:
> I'm looking into ways to manipulate Javascript objects using jQuery,
> and I was wondering if there's anything I can do with the selectors
> when passing an object to jQuery.
>
> For example,
>
> $({
> obj1: {
> name: "a",
> prop: "x"},
>
> obj2: {
> name: "b",
> prop: "y"},
>
> obj3: {
> name: "c",
> prop: "z"
>
> }
> }).filter('[name="a"]');
>
> This returns an empty jQuery array, though. If I don't use a filter
> function, $(...) returns the object with jQuery properties as
> expected.
>
> It seems like passing an object to jQuery is undocumented
> functionality itself so I'd love to know if the obj can be accessed at
> all.

Reply via email to