<!DOCTYPE html> <html> <body> <script> document.addEventListener("DOMContentLoaded", function() { var t = document.querySelector("textarea"); t.focus(); document.querySelector("#dst").appendChild(t); }, false); </script> <div> <textarea>I am a long long long long textarea </textarea> </div> <div id="dst"></div> </body> </html>