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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:04:55+00:00 2026-06-08T00:04:55+00:00

I am getting CSS ‘left’ property value. now it is set on -50. so

  • 0

I am getting CSS ‘left’ property value. now it is set on -50. so i want to get only 50 can this be done with split function or there is another way to do that. Also why split function is not working in my function

<head>

<script type="text/javascript" src="jquery-1.7.2.js"></script>

<script type="text/javascript">

$(document).ready(function() {

$('.box').click(function (){

    var kar=parseInt($(this).css('left'))

var jj= kar.split('')

alert(jj[0])

    })

});
</script>


<style>

.container {

    margin:auto;
    width:500px;
    position:relative

}


.box { background:#FF0000; width:200px; height:200px; position:absolute;left:-50px;}

</style>

</head>

<body>
<div class="container">
<div class="box"></div>

</div>
</body>
  • 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-06-08T00:04:58+00:00Added an answer on June 8, 2026 at 12:04 am

    I think what you are looking for is the Math.abs function:

    Math.abs(-50); // 50
    Math.abs("-50"); // 50
    

    The split function works on strings and returns an array with all parts of the string separated by the given delimiter. You are giving an empty string as delimiter, which splits your string after each character like this:

    "-50".split(""); // result is: ["-","5","0"]
    var kar = -50;
    kar.split(""); // TypeError: kar.split is not a function
    

    If you are getting a string back like "-50px", then you can do it like this:

    var leftAsInt = parseInt("-50px".replace(/[A-Za-z]/g, ""),10);
    console.log(Math.abs(leftAsInt)); // 50
    

    Also: there is no jQuery involved in this (besides the .css() function), split and abs are functions of JavaScript’s predefined core objects String and Math.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in a need of getting a value of another property in CSS. Say
I'm having an issue getting this CSS for a sprite sheet to work on
While validating my CSS on http://jigsaw.w3.org/css-validator/ I am getting following errors: 1.Property zoom doesn't
i'm getting this weird CSS bug in ie6/7 (but not in ie8 or firefox):
I'm getting confused with class inheritance for css. I have this: <ul id='grok'> <li
I am having trouble getting my CSS to look right. I want alternating colors
I am getting two errors in w3 css validtor as Value Error : font-family
I'm having trouble getting my CSS 3 button to operate properly. You can view
When I'm getting this page http://booking.airasia.com/css/AKBase/Cultures/en-GB/far-min.css with node's http , the toString method gives
I have this code,everything works fine but .css('color','red') rule is not getting applied.I tried

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.