In such a code:
var a = e.clientX;
var b = document.getElementById('someElement').style.left;
var z = a - b;
the output is NaN. Viewing the outputs separatly i see, that a
is only numbers whereas b
is numbers ending with 'px'. Setting it var a = e.clientX + 'px';
still doesnt work.
Thanks
I thank you for your suggestions, but the best outcome is 0
with the Number()
method (from the other methods the outcome is NaN). . . any ideas?
parseInt(b)
? – user1499731 Oct 7 '15 at 18:56