简体   繁体   English

jQuery .css('margin-left')在IE7和IE8中返回“自动”

[英]jQuery .css('margin-left') gives “auto” back in IE7 and IE8

I'm trying to get the margin-left value of an element. 我正在尝试获取元素的margin-left值。 This works fine in Chrome, FireFox & IE9 but in IE7 and IE8 I get "auto" back: 这在Chrome,FireFox和IE9中可以正常工作,但在IE7和IE8中,我会得到“自动”返回:

alert($('#'+page+'menubuttoncontainer').css('margin-left').replace('px', ''));

How can I get a number back instead of "auto"? 如何找回电话号码而不是“自动”?

.css return the value of the CSS. .css返回CSS的值。

In order to get the position, you should use the offsets functions: http://api.jquery.com/offset/ 为了获得位置,您应该使用offsets函数: http : //api.jquery.com/offset/

Or the position function: http://api.jquery.com/position/ 或位置函数: http : //api.jquery.com/position/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM