I need to make this comparison:
if (x < siteA.style.left || x > siteA.style.left + land.width() ) {
however siteA.style.left returns 20px (e.g) so the condition doesn't work. How do I remove the px and transform it into an integer so I can work with it?
I tried alert(parseInt(siteA.style.left)) and it returned NaN however alert(siteA.style.left) returned 30px, 60px etc.
Use parseInt:
var leftPos = parseInt(siteA.style.left, 10);
where 10 is the base, good practice to always specify it.
Just use parseInt().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With