While working with a dynmic object positioning work using javascript, i was using jquery and was retrieving position using like this:
var leftPos = jQuery("#content").attr('offsetLeft');
However, this value was giving me two different values for firefox and ie. So, I had to digg more about this problem and tried with a jquery built in function position():
var position = jQuery("#content").position();
//use position.left and position.top for use
This returned me perfect result.
I am not sure why the previous code snippet didn't work as ie and firefox both should support 'offsetLeft'/'offsetRight' attribute. Actually both were working, only was giving different values. But I am happy with this easy solution that jquery provided.
Subscribe to:
Post Comments (Atom)










0 comments:
Post a Comment