Change an input field to an input button:
document.getElementsByTagName("INPUT")[0].setAttribute("type", "button");
Click the button below to change the input field to an input button.
<!DOCTYPE html> <html> <body> <input value="OK"> <button onclick="myFunction()">Test</button> <script> function myFunction() {// w ww .jav a 2 s.c o m document.getElementsByTagName("INPUT")[0].setAttribute("type", "button"); } </script> </body> </html>