按钮有一个value属性,我们可以通过按钮的value属性获得按钮上显示的文本
<!DOCTYPE html> <html> <body> <input type="button" id="button1" value="Click Me!"> <p>The text on the button is: <script> document.write(document.getElementById("button1").value); </script></p> </body> </html>