Grow your CSS skills. Land your dream job.

positioning an element with jquery

  • # September 24, 2010 at 2:35 pm

    Hi there! I am having the worst time troubleshooting jquery right now. As it is right now, I have an image slider that has sections controlled by tabs. I’m looking to reset the slider back when someone clicks on a different tab, but for some reason I can’t figure out how to reset the left position back. I’ve tried the following:



    $(element).css('left', 272.5);
    $(element).offset.left = 272.5;
    $(element).offset().left = 272.5;

    but nothing works. I’m using div’s inside the main sliding element and those are hidden. Does this affect it somehow? Any help is appreciated. Thanks!!

    # September 24, 2010 at 4:34 pm

    left isn’t a CSS property, perhaps margin-left would work.

    Anonymous
    # September 24, 2010 at 5:53 pm

    Well, 2 points I guess:
    1. is there any unit? px? em?
    Example:
    $(element).css(‘left’, ‘272.5px’);

    2. need some css before positioning:

    $(element).css(‘position’, ‘fixed’); // or ‘absolute’.

    # September 24, 2010 at 6:00 pm

    Your syntax is incorrect I believe. Should be:

    $(element).css('left', '272.5px');
    Anonymous
    # September 24, 2010 at 6:04 pm

    You are right. I changed it, thanks.
    Did it help you with your problem?

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

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".