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 7693905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:11:49+00:00 2026-05-31T21:11:49+00:00

My problem is that I am using the .hover method to get the x

  • 0

My problem is that I am using the .hover method to get the x position of a background-img. When i ask typeof it returns as undefined. When i ask it to alert me the returned value it gives me: “10px”, how can I make this an integer value that gets stored in the variable properly?

My function goes as follows:

$("#menu li").hover(  
    function () { 
        var xPos = $(this).css('background-position-x')   
        $(this).stop().animate({
            backgroundPosition: xPos + "px 0px"
         }, 500); 
    },  

    function () {
        var xPos = $(this).css('background-position-x')   
        $(this).stop().animate({
            backgroundPosition:  xPos + "px 35px"
        }, 500); 
    }
);
  • 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-31T21:11:50+00:00Added an answer on May 31, 2026 at 9:11 pm

    You can just remove the ‘px’

    var xPos = $(this).css('background-position-x').slice(0, -2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using qTip: http://craigsworks.com/projects/qtip2 and my current problem is that when I hover
I have a problem using a small div that should hover over pics that
My root problem is that when using calls Dispose on a StreamWriter , it
I'm facing a problem that seems to have no straighforward solution. I'm using java.util.Map
I have a JQuery (using JQuery 1.4.2) problem that exhibits only in IE8 in
I'm using Entity Framework in my project, and I have the problem that, once
I am using swfupload to upload files on a website, the problem that every
I want to make a windowless application. The problem is that I'm using a
Problem: Customer X has requested that pages using XML DataBinding and Databound tables in
I am using TIdHttpServer to process some commands the problem is that some commands

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.