0

I am using an API that delivers the following data / value object:

Object {left: "704.4026794075746px", top: "171.54992155622406px"} 

I need to be able to take the left and top coordinates for use with jquery's css method.

Would I convert this object into a string and then parse the string? How would I go about using the data within the object within jquery's css or animate methods?

Sorry for no context, but I am unsure of where to start here.

3
  • 1
    these are some high-precision coordinates! I want to see the monitor that benefits from them! Commented Apr 22, 2013 at 20:00
  • @StenPetrov LOL that seems very very precise. Commented Apr 22, 2013 at 20:06
  • Haha they are dynamically created for ULTIMATE precision! Commented Apr 22, 2013 at 20:12

2 Answers 2

1

You just pass that object into jQuery's .css function.

$('selector').css(cssObject);
Sign up to request clarification or add additional context in comments.

1 Comment

No problem @JCHASE11 I am happy to help! ^_^
0

If the object is in a variable named someObject, you access the properties as:

someObject.left

and

someObject.top

You can us it in a call to css():

$('selector').css("left", someObject.left);

Or you could pass the whole object as Neal showed in his answer.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.