Im building a draggable map that when the map is dragged the element is given a ‘left’ and ‘top’ attribute with values for each as so…
<div class="map" style="top:200px; left:100px;">Map</div>
I have a button that I want to remove the top and left attribute from the inline style on the div when clicked, Is this possible with jquery?
The default values for CSS
topandleftareauto, so setting them to that might be equivalent depending on what you’re trying to do:You also have the option of wholly removing the
styleattribute: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.