The 'top' value can be effectively disabled by using the 'initial' value which would set the property to its default value. It is similarly done with the 'left' value. This will remove the effect of the 'top' and 'left' values in the element.
To remove all attributes of elements, we use removeAttributeNode() method.
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.
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', '');
Simply set the CSS property with an empty string, for example with the following code:
$('#mydiv').css('color', '');
See jQuery Documentation on CSS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With