Search code examples
javascriptjqueryhtmlpositioning

Convert absolute position to relative


Is it possible to change DIV position from absolute to relative (and from relative to absolute)? DIV should remain on same place.


Solution

  • you can change that attribute with

    $(object).css({position: 'absolute'});
    

    For instance:
    You could use jQuery's methods .position() or .offset() to set "top" and "left" css attribute aswell, that way your object should stay at it's position changing from relative -> absolute.

    I don't think that works vice versa.

    demo code: http://jsbin.com/uvoka