How to remove only position(top and left) of Style attr using JQuery?

javascript, jquery

Solution

Perhaps, your best Bet would be to simply put them to their default value. Top and left have the default value "auto". So:

jQuery(selector).css({
   'top': 'auto',
   'left': 'auto'
})

Problem

I am dynamically setting the position attr of the element only when the view is out of viewport of the window, in other case default value is set from the css file , ``` .css( { "left": (left + 20) + "px", "top": (top+10) + "px" } ); ``` Once the dynamic position is set, I want to remove the position attr alone. I can remove style attribute it will also my display property of style which is required. Is there a way to to remove the position attr alone?

Original source