parseInt($("div").css("left"), 10); When I try to get the value left , some browsers giv...">

ParseInt% and px problem

<div style="left: 100%"></div> parseInt($("div").css("left"), 10); 

When I try to get the value left , some browsers give the result in pixels, some in%.

Here is an example http://jsfiddle.net/WTt4s/1/

Google Chrome gives a percentage value, IE9 instead selects pixels.

How to get the same value in all browsers (px or%)?

+6
source share
2 answers

Try this parseInt($("div")[0].style.top, 10)

+4
source

Try instead of .offset().top or .position().top

0
source

Source: https://habr.com/ru/post/887623/


All Articles