如何if
在日期选择器中为特定日期设置条件?
例如,当用户在日期选择器中插入特定日期时,会出现一条消息并报告是否存在事件。
function myFunction() {
var x, text;
// Get the value of input field with id="test"
x = document.getElementById("test").value;
if (x == "07/21/2019") {
text = "Birthday event";
} else {
text = "No events";
}
document.getElementById("demo").innerHTML = text;
}
<p>make if conditional for a specific day in datepicker</p> <input id="test" type="date"> <button type="button" onclick="myFunction()">Submit</button>
<p id="demo"></p>