lundi 22 décembre 2014

JQuery Conditional Working Incorrectly

This is a weird one, but probably simple.


I am doing a simple if to check for the lowest number. I have debug statements and they are showing me that JQuery is returning that 10<2 is true.


Here is the code:



var lowID = 50;

$('.tip').each(function() {
console.log('Tip id = ' + this.id);
if(this.id < lowID){
console.log(this.id + '<' + lowID);

lowID = this.id;
}
});


And here the debugs:



"Tip id = 2" lightbox.js:6
"2<50" lightbox.js:8
"Tip id = 3" lightbox.js:6
"Tip id = 4" lightbox.js:6
"Tip id = 5" lightbox.js:6
"Tip id = 6" lightbox.js:6
"Tip id = 7" lightbox.js:6
"Tip id = 8" lightbox.js:6
"Tip id = 9" lightbox.js:6
"Tip id = 10" lightbox.js:6
"10<2" lightbox.js:8
"Tip id = 11" lightbox.js:6
"Tip id = 12" lightbox.js:6
"Tip id = 13" lightbox.js:6
"Tip id = 14" lightbox.js:6
"Tip id = 15"


For some reason whenever it reaches 10 it says that 10 is less than anything


PLEASE HELP me this might be the weirdest problem ive seen in a while.


Aucun commentaire:

Enregistrer un commentaire