突出显示一周的开始 Javascript/JQuery UI 日期选择器
我的日期选择器正在工作,并且功能齐全。
从上图可以看出,周选择器是有效的。不过,我希望日期选择器突出显示当前一周。在这个例子中应该突出显示整个一周的开始。我希望它看起来像这样或类似
这是如何完成的?
已编辑 理想情况下,当页面加载时,我希望突出显示当前星期,而不是用户必须自己选择星期。在提供的示例中,当前选择了日期,但我希望自动选择当前星期。如下所示
I have the datepicker working and it is fully functional.
From the above image it can be seen that the week picker works. However I would like the datepicker to highlight the current week. Which in this example should highlight whole of the start of the week. Which I would like to look like this or similar
How is this done?
Edited
Ideally when the page loads up I would like the current week to be highlighted instead of the user having to select the week themselves. In the example supplied, the day is currently selected but I wish to have the current week automatically selected. Like below
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所选的
TD
具有类ui-datepicker-current-day
,因此这可能就是您想要查找的内容。您可以通过将点击事件附加到 datepicker 元素来突出显示,例如,您可以根据您的喜好定义
highlight
和highlight2
类。请注意,
onSelect
事件并不能解决问题,因为每次单击日期时都会刷新日历。这是一个示例: http://jsfiddle.net/9DdfL/2/
The
TD
that is selected has the classui-datepicker-current-day
, so that might be what you want to find. You can do the highlighting by attaching a click event with the datepicker element, e.g.And you can define the
highlight
andhighlight2
classes to your heart's content.Note that, the
onSelect
event does not do the trick, as the calendar is refreshed each time a date is clicked.Here is an example: http://jsfiddle.net/9DdfL/2/
日期选择器中的每一行日期都是一个
。包含今天日期的
元素具有类
ui-datepicker-today
。因此,您可以搜索该元素的父元素以获取相应的 tr 并为其分配您想要的任何类:
$(".ui-datepicker-today").parent().addClass(...)
each row of dates in the datepicker is a
<tr>
. the<td>
element which contains today's date has the classui-datepicker-today
.therefore, you can search for the parent of this element to get the corresponding tr and assign whatever class you want to it:
$(".ui-datepicker-today").parent().addClass(...)