<html>
<body>
年和月:<input type="month" id="myMonth" value="2023-06">
<p>单击该按钮可显示月份字段的月份和年份。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myMonth").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>