开发者

jQuery CSS in different browsers

When I'm trying to use jQuery like this: $('#myDiv').css('left')

In chrome it returns 10% wh开发者_如何学Goich is what I expected because I set the left value as 10%;

But in firefox it returns value in px? How can I always get the 10%?

Thanks


So I think to get same results from all browsers it's better to let it return offset values.


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

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

This may not be in % as you want, but will be the same in all browsers. You might want offset() rather than position, if you want the position relative to the parent container.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜