javascript - Simple math addition in JS giving wrong result -


i have strange problem can't head around. try find highest number in list of elements have data-index attribute respective number. when iterating on them, js insists 9 < 10 false.
see fiddle: http://jsfiddle.net/1ztbxbjx/

what i'm doing wrong?

i can't use

for (i = 0; < $('div[data-index]'; i++))

sometimes there numbers out of order in list (eg. 1,2,3,4,5,25,31).

you need parse id, otherwise you're comparing strings. here example using parseint()


Comments

Popular posts from this blog

how to do line continuation in perl debugger for entering raw multi-line text (EOT)? -

android - Linear layout children not scrolling -

javascript - Create websocket without connecting -