Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery css('left', ... ) position bug?

Tags:

jquery

With jquery I wrote the following highly complex code:

val = 100;
n.css('left', val /* + 'px' */);
console.log(val, n.css('left'));

The console output of it is:

100, "90px"

why is that so...?

Thanks in advance for some help

EDIT: Here's an example: http://jsfiddle.net/RaznH/1/ You need to have your browser zoomed out (e.g. with "ctrl -") and the console opened in order to have the effect appear

like image 417
Doidel Avatar asked Mar 25 '26 06:03

Doidel


1 Answers

You need to have a position other than static (relative,absolute or fixed) declared on your element or else it won't work.

Taking the example from the comments: http://jsfiddle.net/VqH9x/1/ everything works fine when you declare a proper position.

like image 68
Christoph Avatar answered Mar 27 '26 20:03

Christoph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!