Reputation: 375
Is there a way in jQuery that we can do something like:
$('#element').css('margin-left',-=10);
The purpose is for propeties like Left, Right, Width, Height, Margins, Paddings,... Thank you!
Upvotes: 1
Views: 414
Reputation: 12400
Yes, this is possible. The syntax is just a little bit different.
$('div').css('margin-left',"-=10px");
div{margin: 40px; background: red; height: 20px; width: 20px;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div></div>
Upvotes: 2
Reputation: 16369
You're trying a shorthand (that I don't think exists) for a pretty straightforward application of an explicit getter:
const $element = $('#element');
$element.css('margin-left', $element.css('margin-left') - 10);
Upvotes: 0