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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:03:40+00:00 2026-05-23T15:03:40+00:00

Here is some simple code that takes the id values of .somedivs and puts

  • 0

Here is some simple code that takes the id values of “.somedivs” and puts them into global variables to be sorted by the conditional statements, then to the console. Below you can see that I am getting some weird results and no matter what combination of conditionals I use I can’t get it to work right. Seems so basic, I’m thinking I’m violating some law of js or i’m missing something obvious.

  $(document).ready(function(){

    $('.somedivs').mousedown(function(){
      first = $(this).attr("id");
    }).mouseup(function(){
      second = $(this).attr("id");

      if(window.first > window.second){
        var higher = window.first;
        var lower = window.second;
        var process = 1;
      }else if(window.second > window.first){
        var higher = window.second;
        var lower = window.first;
        var process = 2;
      }else if(window.first === window.second){
        var higher = window.first;
        var lower = window.second;
        var process = 3;
      }


      if(higher > lower){
        var status = true;
      }else{
        var status = false;
      }

      console.log("process = " + process + " // " + "window.first = "+window.first+" / window.second = "+window.second + " // higher = "+higher+" / lower = "+lower + " // status = "+ status  );


    });

Console output, as you can see most of the lines are returning true when they should be false, if you look at the numbers themselves. I marked some of the ones that are wrong with the arrow “>”. Why is status true when it should be false?

process = 2 // window.first = 0 / window.second = 1 // higher = 1 / lower = 0 // status = true
process = 3 // window.first = 2 / window.second = 2 // higher = 2 / lower = 2 // status = false
process = 1 // window.first = 2 / window.second = 0 // higher = 2 / lower = 0 // status = true
> process = 1 // window.first = 5 / window.second = 22 // higher = 5 / lower = 22 // status = true
process = 3 // window.first = 7 / window.second = 7 // higher = 7 / lower = 7 // status = false
process = 2 // window.first = 3 / window.second = 9 // higher = 9 / lower = 3 // status = true
process = 1 // window.first = 19 / window.second = 14 // higher = 19 / lower = 14 // status = true
> process = 1 // window.first = 5 / window.second = 11 // higher = 5 / lower = 11 // status = true
process = 1 // window.first = 35 / window.second = 23 // higher = 35 / lower = 23 // status = true
process = 2 // window.first = 13 / window.second = 17 // higher = 17 / lower = 13 // status = true
process = 1 // window.first = 32 / window.second = 24 // higher = 32 / lower = 24 // status = true
process = 2 // window.first = 17 / window.second = 18 // higher = 18 / lower = 17 // status = true
process = 1 // window.first = 22 / window.second = 18 // higher = 22 / lower = 18 // status = true
> process = 1 // window.first = 8 / window.second = 11 // higher = 8 / lower = 11 // status = true
process = 1 // window.first = 18 / window.second = 14 // higher = 18 / lower = 14 // status = true
process = 2 // window.first = 3 / window.second = 6 // higher = 6 / lower = 3 // status = true
process = 1 // window.first = 24 / window.second = 16 // higher = 24 / lower = 16 // status = true
process = 1 // window.first = 9 / window.second = 15 // higher = 9 / lower = 15 // status = true
process = 1 // window.first = 31 / window.second = 26 // higher = 31 / lower = 26 // status = true
process = 2 // window.first = 24 / window.second = 28 // higher = 28 / lower = 24 // status = true
process = 1 // window.first = 41 / window.second = 30 // higher = 41 / lower = 30 // status = true
process = 2 // window.first = 13 / window.second = 19 // higher = 19 / lower = 13 // status = true
  • 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-23T15:03:41+00:00Added an answer on May 23, 2026 at 3:03 pm

    I thinik it is because of the type of the variable:

    try :

    first = parseInt($(this).attr("id")); 
    

    and

    second = parseInt($(this).attr("id"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is some simple code: DIR* pd = opendir(xxxx); struct dirent *cur; while (cur
I've got a quite strange problem here. I'm calling some simple code via Ajax.Updater:
Here I have a simple php script which displays some values from a database
I have some simple function that takes in a value This value is the
I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
Here is some simple Perl to count the number of times a value occurs
This is similar to (but different from) this question . Here is some simple
How do you make a grid width 100% inside a canvas? Here's some simple
What am I doing wrong here: class Helo { // main: generate some simple
Have a simple form (only extract fields here) but for some reason the JQserilization

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.