คุณสมบัติค่าปุ่ม HTML DOM เชื่อมโยงกับแอตทริบิวต์ค่าขององค์ประกอบ ระบุค่าที่ซ่อนอยู่ของปุ่ม ค่าคุณสมบัติชุดหรือส่งกลับค่าของค่าแอตทริบิวต์ของปุ่ม โดยทั่วไปแล้วเบราว์เซอร์จะส่งข้อความค่าเมื่อคลิกปุ่ม ในขณะที่เบราว์เซอร์อื่นๆ ส่งข้อความระหว่างองค์ประกอบ ไวยากรณ์ ต่อไปนี้เป็นไวยากรณ์สำหรับ − การตั้งค่าคุณสมบัติ - buttonObject.value = text ในที่นี้ ค่าคุณสมบัติข้อความคือค่าเริ่มต้นที่กำหนดให้กับปุ่ม ตัวอย่าง ให้เราดูตัวอย่างของคุณสมบัติค่าปุ่ม - <!DOCTYPE html> <html> <body> <button id="Button1" name="random" value="FirstButton">My Button</button> <p>Click on the below button to change the above button value</p> <button onclick="changeFunc()">CHANGE</button> <p id="Sample"></p> <script> function changeFunc() { document.getElementById("Button1").value = "SecondButton"; var x=document.getElementById("Button1").value; document.getElementById("Sample").innerHTML="The button value is now "+x; } </script> </body> </html> ผลลัพธ์ สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ - เมื่อคลิกเปลี่ยน - ขั้นแรกเราได้สร้างปุ่มที่มีค่า “FirstButton” พร้อมรหัส “button1” <button id="Button1" name="random" value="FirstButton">My Button</button> เราได้สร้างปุ่ม CHANGE ซึ่งจะรัน changeFunc() เมื่อคลิก <button onclick="changeFunc()">CHANGE</button> เมธอด changeFunc() จะได้รับองค์ประกอบปุ่มแรกโดยใช้รหัส "Button1" และเปลี่ยนค่าจาก "FirstButton" เป็น "SecondButton" จากนั้น ค่าปุ่มที่เปลี่ยนแปลงใหม่จะถูกกำหนดให้กับตัวแปร x และจะแสดงในย่อหน้าด้วย id “Sample” function changeFunc() { document.getElementById("Button1").value = "SecondButton"; var x=document.getElementById("Button1").value; document.getElementById("Sample").innerHTML="The button value is now "+x; }