JQuery CSS in different browsers

When I try to use jQuery as follows: $ ('# myDiv'). css ('left')

In chrome, it returns 10%, which I expected, because I set the left value as 10%;

But in firefox, does it return a value in px? How can I get 10%?

thanks


So, I think that getting the same results from all browsers is better to return offset values.

+4
source share
1 answer

I believe you can get a consistent answer from ...

var position = $('#myDiv').position(); var left = position.left; 

It may not be in% as you want, but it will be the same in all browsers. You may need offset (), not a position, if you want the position to refer to the parent container.

0
source

All Articles