Let's say I have something.style.top = "Ypx", how to extract and increment that Y, if Y can be either negative or positive? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 6

Let's say I have something.style.top = "Ypx", how to extract and increment that Y, if Y can be either negative or positive?

Y < innerHeight

5th Sep 2020, 7:41 AM
šŸ‡ Alex Tușinean šŸ’œ
šŸ‡ Alex Tușinean šŸ’œ - avatar
2 Respostas
+ 6
something.style.top = parseInt(something.style.top)+1 + "px" Or something.style.top = +something.style.top.slice(0,-2)+1 + "px"
5th Sep 2020, 7:51 AM
Namit Jain
Namit Jain - avatar
+ 2
parseFloat might be better.
5th Sep 2020, 8:15 AM
Nor'wester šŸŒŖļø šŸ‡§šŸ‡© (INACTIVE)
Nor'wester šŸŒŖļø šŸ‡§šŸ‡© (INACTIVE) - avatar