Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7050677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:10:20+00:00 2026-05-28T03:10:20+00:00

I am trying to add some pixels from an element on my page. This

  • 0

I am trying to add some pixels from an element on my page. This is so I can create a new element and place it above it.

 posy = document.getElementById('user').style.top + 20;

But it is returning “50px20”, I haven’t tried subtracting it yet, but what should I do to prevent it from returning ‘px’ in it?

Is there a way to do this in jQuery?

Thanks,
Alex.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:10:21+00:00Added an answer on May 28, 2026 at 3:10 am

    What you are asking is a little confusing. You say you want the top attribute, but this could be the position of the element on the page or the top value of its style. There is a distinct difference. It sounds like you want the position of the element because you are storing the results in posy. This is different than getting the top value of the CSS which will only exist if it has been defined in your stylesheet.

    To get the top CSS value in jQuery you would use

    $('selector').css('top');
    

    To get the position of the element use jQuery’s offset() or position() methods. You probably would want offset.

    $('selector').offset().top; //or .left
    

    To fix your returned value for px or em try parseInt.

    parseInt(value);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add some additional logic to the 'Promoted to front page'
I'm trying to add some html markup to the WYSIWYG CLEditor from outside of
I am trying to add some functionality to a page I have inherited, but
I'm trying to add some user controls on a page. Thats easy, I just
I'm trying add some code at run time to the head element. When I
Hi I'm trying to add some another field to this php contact form I
I'm trying to add some Hibernate functionality to a Spring web application. This is
i'm trying to add some custom attributes to the checkout(sales) page of magento 1.5.1.0
I'm trying to add some settings to my WordPress options page that depend on
Im trying to add some short file names to a Wise installer to fix

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.