0

Wird, I thought this is obvious but not necessarily, can anybody tell me how to detect margin with jQuery? I have this and in console i have good result but it's not working on page:

var margin_left = circle.css('margin-left').toLowerCase();
circles_container.css('margin-left', -margin_left + 'px');

Much thx for help.

Lukas
  • 7,384
  • 20
  • 72
  • 127

4 Answers4

2

I would say this should be more accurate:

var margin_left = circle.css('margin-left');
circles_container.css({marginLeft: '-'+margin_left});
A. Wolff
  • 74,033
  • 9
  • 94
  • 155
0

OK i have this and also it's work:

var margin_left = l_circle.css('margin-left').replace("px", "");
container.css('margin-left', -margin_left + 'px');
Lukas
  • 7,384
  • 20
  • 72
  • 127
0

Try this -

var marginLeftVal = circle.css('marginLeft');
marginLeftVal = parseInt(marginLeftVal)*-1;
circles_container.css({
            marginLeft: marginLeftVal 
});
Rohit Agrawal
  • 5,372
  • 5
  • 19
  • 30
-1

YOu could also start using the JSizes library.

Found on this page: http://www.bramstein.com/projects/jsizes/

Allows you to easily retrieve or set a property of margin, padding, or other attributes.

lt.kraken
  • 1,287
  • 3
  • 10
  • 27