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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:59:50+00:00 2026-05-24T11:59:50+00:00

var x = e.pageX; var myX = $(this).html(); var difference = myX – x;

  • 0
var x = e.pageX;
var myX = $(this).html();
var difference = myX - x;
var ex = myX + difference;

Everything workes until the last row. It doesn´t make an addition, it puts together the variables into one string. If myX is 10 and difference is 20 it will be 1020 when I want it to be 30.

How do I solve this?

  • 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-24T11:59:52+00:00Added an answer on May 24, 2026 at 11:59 am

    You can force the variables to be integer using something like this :

    var ex = parseInt(myX, 10) + parseInt(difference, 10);
    

    This happen because your variables are considered as strings, and using the + operator on strings concatenates then togheter instead of adding their numeric values.

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

Sidebar

Related Questions

this.progress.click(function(e) { // works var seek = (e.pageX - this.offsetLeft) / $(this).width(); self_ref[index].seek(seek *
I have this code : function move() { $(document).mousemove(function(e){ var x = e.pageX; $('.linkHover').animate({'right':
$(#canvas).mousedown(function(e){ var X1 = (e.pageX - this.offsetLeft) - 8; var Y1 = (e.pageY -
My code: $('.colorPick').click(function(e) { var x = e.pageX - this.offsetLeft; var y = e.pageY
jQuery("body").dblclick(function(event){ var x = event.pageX - this.offsetLeft; var y = event.pageY - this.offsetTop; jQuery("<div></div>").addClass("node").css("position","absolute")
let say I want to do this: var dashboard = {}; var page =
Okay, I have this code: <script language=javascript type=text/javascript> <!-- function requestPage(page) { var request
I have a var that contains a full html page, including the head, html,
When running on an xhtml page, xpath doesn't seem to return any results. var
<script type=text/javascript> var x = 0; //this occurs in the beginning of the page.

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.