2011-01-27 56 views
-1

可能重复:
Position an element from the end of the document at the top of the page的JavaScript - 移动从文件末尾一个元素刚过<body>

<div id="debug"> 
    blabla 
    </div> 
</body> 

我如何可以移动#调试div在文件开头之后,<body>之后,只用javascript?

+2

为什么张贴重复?你总是可以编辑你的文章(http://stackoverflow.com/questions/4814007/css-position-a-element-from-the-end-of-the-document-at-the-top-of-the-page/4814027#4814027)提供更多信息? – Chandu 2011-01-27 08:26:31

+0

我以为人们会忽略它,因为它最初被标记为css :) – Alex 2011-01-27 08:30:29

回答

1

Javascript或jQuery的?在jQuery的使用:

$('body').append($('#debug')); 
1
var element = document.getElementById('debug'); 
document.body.insertBefore(element, document.body.firstChild);