jquery datepicker get the date on mouseover from the cell

杀马特。学长 韩版系。学妹 提交于 2019-12-08 14:39:28
var month = $(this).closest('.ui-datepicker').find('.ui-datepicker-month').text();
var year  = $(this).closest('.ui-datepicker').find('.ui-datepicker-year').text();

Just like Yoda mentioned you will want to use the live method to attach the event on the document so any created elements that match the selector behave the same way.

You will end up with something like this:

<h1></h1>

<label for="pickDate"/>
<input type="text" id="pickDate"/>

$(function() {
    $("#pickDate").datepicker();
    $(".ui-state-default").live("mouseenter", function() {
        $("h1").text($(this).text());
    });
});

Example on jsfiddle

The calendar is made after the DOM is ready, so that will never work unless you use a method like this :

http://api.jquery.com/live/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!