[英]jQuery date picker function
I have a date picker function in jQuery that allows the user to select a date. 我在jQuery中有一个日期选择器功能,该功能允许用户选择一个日期。 In the HTML I have some text in a
<p id="dateText">
, which is hidden. 在HTML中,我在
<p id="dateText">
有一些文本是隐藏的。 I'm trying to allow when the text box is not empty (ie a date is selected) to allow the dateText value to show and fade in. I'm not sure if I can compare html and javascript within a jquery function, I just started learning it a few days ago. 我试图允许当文本框不为空(即选择一个日期)时,以允许dateText值显示和淡入。我不确定是否可以在jQuery函数中比较html和javascript,我只是几天前开始学习它。 Here is what I have for it but it won't work.
这是我所拥有的,但无法使用。 Thanks in advance.
提前致谢。
$(function() {
$("#datePick").datepicker(); // id of text box in html
if (datePick.value ==="") {
$("#dateText").hide(); // id of <p> text in html
}
else {
$("#dateText").fadeIn("slow");
}
});
If you want to perform a test when the user selects something from the datepicker, put it in the onSelect
callback function. 如果要在用户从日期选择器中选择某项时执行测试,请将其放入
onSelect
回调函数中。
$(function() {
$("#datePick").datepicker({
onSelect: function() {
if (this.value === "") {
$("#dateText").hide();
} else {
$("#dateText").fadeIn("slow");
}
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.