Wednesday, April 11, 2012

jquery 1.7.2 bug?

I've a dom which is set to position: relative, style.left to 0

console.log($(target)); //return array of 1 object

$(target).css("left", "100px");
console.log(dom.style.left); //seems to return 100px, which is correct

but when i run
$(target).css("left"); // return 110px

Updates:
$(target).position() - returns position from parent offset
$(target).offset() - returns position from the screen

Example:
The only work around method i could think of is to directly set:
position: relative;
top: 0;
left: 0;
Or
jQuery(target).offset(jQuery.target.offset());

Then use dom.style.left or dom.style.top directly.


Please note that this is tested on linux chromium browser 18.

No comments: