Remove CSS "top" and "left" attributes with jQuery
You can remove all of the contents in the style
attribute by doing:
$('.map').removeAttr('style');
And you can remove specific style
s by doing:
$('.map').css('top', '');
$('.map').css('left', '');
If you want to specifically remove top and left attributes and leave others, you can do this:
$('.map').css('top', '').css('left', '');
Or, a shorter equivalent:
$('.map').css({
'top': '',
'left': ''
});
The default values for CSS top
and left
are auto
, so setting them to that might be equivalent depending on what you're trying to do:
$('.map').css('top', 'auto').css('left', 'auto');
You also have the option of wholly removing the style
attribute:
$('.map').removeAttr('style');
However, if you're using other jQuery UI components, those may require inline styles that you don't want to be removed, so proceed with caution there.
Simply set the CSS property with an empty string, for example with the following code:
$('#mydiv').css('color', '');
See jQuery Documentation on CSS.