views:

171

answers:

2

Hi , iam dinamiclly setting the postion 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 ?

+1  A: 

I'm not sure if you're asking for removing a position HTML attribute, a position style, or top and left styles. In any case, you can remove any attribute with $.removeAttr(), and you can remove (dynamically assigned) styles with $.css({ styleName: '' });

Edit: it seems you want $.css({ position: '' }), or more likely $.css({ position: 'static' }), as that is the default value.

eyelidlessness
i would remove a position style , but if i use $.removeAttr() it will remove the entire style not the left and top alone
ravikiran
+3  A: 

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'
})
Mike