Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
  
  div.box {background-color: red; position: absolute; width: 200px; height: 50px;}
</style>
</head>
<body>
  <p>and some more gap...</p>
  <p id="hello">Hello World</p>
  <div>Some gap here</div>
  <p>and some more gap...</p>
  <p>and some more gap...</p>
  <p>and some more gap...</p>
  <p>and some more gap...</p>
  <button id="mybutton">be absolute now!</button>
  <p>and some more gap...</p>
  <div class="box">test123</div>  
  <p>and some more gap...</p>
  <p>and some more gap...</p>
  <p>and some more gap...</p>
  <p>and some more gap...</p>
</body>
</html>
 
  $('#mybutton').bind('click', function(e){
    
    var $change = $(".box"),
        pos = $change.position();
    $change.css({top: pos.top+19, left: pos.left, position: 'static'});
    $change.text(pos.left);
  });
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers