Alex Rivera | Logout

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

Asked 2009-09-29T05:50:19.173
11

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?

Edit
Report

1 Answer

30

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'
})
answered 2009-09-29T06:22:35.123

Your Answer