Give help. Get help.

  • # April 20, 2013 at 6:20 am


    I’m curious if there is a preferred method for writing the following jQuery animation syntax.

    **Method One**

    $(‘.box’).animate({ left: -20 }, 400, ‘linear’);

    **Method Two** (pixels defined)

    $(‘.box’).animate({ left: “-20px” }, 400, ‘linear’);

    Also…is there a difference in single and double quotes? For example, **”-20px”** and **’-20px’**

    Thanks for any suggestions

    # April 20, 2013 at 7:04 am

    There is no difference between using `”` and `’`, people say there is but I have never seen anything to suggest either one is slower or faster than the other.

    As for the animation syntax you can generally just leave off the `px` and use integers as jQuery defaults everything to a pixel value anyway.

    # April 20, 2013 at 2:38 pm

    I prefer using direct numbers over defining the value as px.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.