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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:38:01+00:00 2026-05-26T18:38:01+00:00

I’m trying to wrap up my script placeholderRX. All I need to do is

  • 0

I’m trying to wrap up my script placeholderRX. All I need to do is get the ‘px’ off the end of the string returned from this call.

$(form).children('.inputSpan').each(function() {
   var $input = $(this)
   var $padding = $input.children('.input').css('padding-left');
});

This returns “6px”. I want to trim the 6 px off and make sure it’s an integer so I can then add 2 pixels to it and feed it to the css rule. I’m new to string manipulations in javascript. Help me out!

  • 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-26T18:38:02+00:00Added an answer on May 26, 2026 at 6:38 pm

    You can use a basic javascript replace(), parseInt(), or parseFloat() function to remove “px” from your result. Which method you use, depends on what exactly you need.

    The following is a shortened version of your code using parse replace() to remove “px”.

    $(form).children('.inputSpan').each(function() {
       var padding = $(this).children('.input').css('padding-left').replace("px", "");
    });
    

    In the above code, “16px” will return “16”. “16.7px” will return “16.7px”. “16em” will return “16em”.


    The following is a shortened version of your code using parse parseInt() to remove “px” and more.

    $(form).children('.inputSpan').each(function() {
       var padding = parseInt($(this).children('.input').css('padding-left'));
    });
    

    In the above code, “16px” will return “16”. “16.7px” will return “16”. “16em” will return “16”. As opposed to the first replace() example, this will remove any text, not just “px”.


    The following is a shortened version of your code using parse parseDouble() to remove “px” and more.

    $(form).children('.inputSpan').each(function() {
       var padding = parseDouble($(this).children('.input').css('padding-left'));
    });
    

    In the above code, “16px” will return “16”. “16.7px” will return “16.7”. “16em” will return “16”. As opposed to parseInt(), this keeps decimals, if you have them for some reason.


    Of course, you can keep the code lengthy if there is a reason to see the broken up steps taken for future reference, or if the other variables are used for other reasons. This is the long version using parseInt().

    $(form).children('.inputSpan').each(function() {
        var $input = $(this)
        var padding = $input.children('.input').css('padding-left');
        var paddingInt = parseInt(padding);
    });
    

    Also, to explain the change in the variable name from $padding to padding. A $ symbol in front of a javascript variable is common usage to distinguish regular javascript variables from jQuery variables, as they have different properties. There is no reason to use $padding because .css() does not return a jQuery object, but rather just a simple string.

    In addition, for more complicated searches, you can research regular expressions.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.