ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
**实例效果如下图** ![](https://box.kancloud.cn/755bdb6e117a51c60759b3b05cb64a3b_584x151.png) ~~~ <html> <head> <meta charset="utf-8"> </head> <body> </body> </html> <script language="javascript"> var o = document.body , userName , btLogin ; //定义变量实现IE6.0和IE7.0兼容。 try { userName = document.createElement("<input>"); // btLogin = document.createElement("<input>"); btLogin = document.createElement("<button>"); } catch (e) { userName = document.createElement("input"); // btLogin = document.createElement("input"); btLogin = document.createElement("button"); } userName.id ="userName"; userName.value ="小明"; o.appendChild(userName); // btLogin.id ="btLogin"; // btLogin.type ='button'; // btLogin.value ="提交"; // o.appendChild(btLogin); btLogin.id ="btLogin"; btLogin.innerText ="提交"; o.appendChild(btLogin); var getUserName = document.getElementById("userName"); var btLogin = document.getElementById("btLogin"); console.log( getUserName.value); console.log( btLogin.value); console.log( btLogin.innerText); </script> ~~~