How can I get a value out of a jQuery object?

Posted by Jannis on Stack Overflow See other posts from Stack Overflow or by Jannis
Published on 2010-05-20T00:42:05Z Indexed on 2010/05/20 0:50 UTC
Read the original article Hit count: 349

Filed under:
|
|
|

I am returning some data (example below) and saving it to a jQuery object (or is this an array and I am confusing the two?) when I log the variable that is the object it has the values I am looking for but how do I access the data inside this object?

code

$itemPosition = {
    'top': $item.offset().top,
    'left':$item.offset().left
},

console.log($itemPosition);

This would log out (the in this case expected) top: 0 & left: 490.

But how can I know work with those values?

Also, while this it is probably obvious I am still in the early stages of learning jQuery/Javascript rest assured that reference books are on their way, but so far the SO community has been invaluable to my learning, so thanks for reading!

J.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about arrays