简体   繁体   中英

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

I'm trying to get the margin-left value of an element. This works fine in Chrome, FireFox & IE9 but in IE7 and IE8 I get "auto" back:

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.

In order to get the position, you should use the offsets functions: http://api.jquery.com/offset/

Or the position function: http://api.jquery.com/position/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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