web代码如下:
<!DOCTYPE html> <html> <head> <title>jsTest02.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> </head> <script> function a(){ var aa = 123456; document.getElementById("aaa").value = aa; } function b(){ var bb = "你好,在吗?"; document.getElementById("aaa").value = bb; } window.onload=a; </script> <body onload="a()"> <input type="text" name="" id="aaa"><button onclick="b()">获取js里面的值</button> </body> </html>
代码运行效果显示如下: