开发者

parseInt % and px problem

开发者 https://www.devze.com 2023-03-04 19:50 出处:网络
<div style=\"left: 100%\"></div> parseInt($(\"div\").css(\"left\"), 10); When I try to get value of left, some browsers give result in pixels, some in %.
<div style="left: 100%"></div>

parseInt($("div").css("left"), 10);

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

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

Google Chrome gives percent value, IE9 gives pixels 开发者_开发技巧instead.

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


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


Try to use .offset().top or .position().top instead

0

精彩评论

暂无评论...
验证码 换一张
取 消