0

I'm using sortable, I need to remove the margin-right and not just leave it as 0. I have problems if you use margin-right 0 to sortable. He wins by default margin by jquery. So no use class change, and can not use remove.attr ("style"), because would remove all the CSS.

Carol Skelly
  • 351,302
  • 90
  • 710
  • 624
Giovane
  • 13
  • 1
  • 1
  • 5

1 Answers1

8
$('selector').css('margin-right', '');
tbleckert
  • 3,763
  • 4
  • 32
  • 39
  • 1
    This works if you have jQuery set the margin-right initially but if it is in CSS i.e. `.fred{margin-right:4em; margin-left:6px; border:solid green 1px; display:inline-block;}` it would fail to actually remove and would get set to `4em` in this example. Which is known and documented, see comment on the question. http://jsfiddle.net/e9Y28/ - I tested using Chrome – Mark Schultheiss May 14 '13 at 14:30
  • Well, that's not the case here. If he had set the margin in CSS, then he could just remove it. – tbleckert May 14 '13 at 18:52
  • this code did not work for me. $('selector').css('margin-right', '0px'); did however. In my case the margin was set in a style sheet, on the 'body' selector – 2b77bee6-5445-4c77-b1eb-4df3e5 May 18 '17 at 20:57