<html>
<body>
生日: <input type="date" id="myDate" name="bday">
<p>点击按钮显示或修改 date 字段 name 属性的值。</p>
<button onclick="display()">显示名称</button>
<button onclick="change()">修改名称</button>
<script>
function display() {
var x = document.getElementById("myDate").name;
alert("The name of the date field is: " + x);
}
function change() {
var x = document.getElementById("myDate").name = "newDateName";
alert ("The name was changed to: " + x);
}
</script>
</body>
</html>