<!DOCTYPE HTML> <html> <head> </head> <body> <input type='text' value=12> <script> var elem = document.querySelector('[type = text]'); elem.focus(); elem.value = '12'; </script> </body> </html>