这是 JS fiddle :
$("#datepicker").datepicker({ dateFormat: 'dd/mm/yy', beforeShowDay: myFunction});
function myFunction(input, inst)
{
alert(inst);
}
根据文档:http://docs.jquery.com/UI/API/1.8/Datepicker#event-beforeShow
beforeshowDay
方法接受输入并安装。不过 inst 似乎总是未定义。这让我有些悲伤,因为我需要掌握日期选择器本身。
有解决办法吗?
最佳答案
beforeshowDay
回调只有一个参数;根据文档,一个 date
对象。然而,正如您所提到的,beforeShow
回调有 2 个参数。
演出日之前
- http://docs.jquery.com/UI/API/1.8/Datepicker#event-beforeShowDay
查看此演示:http://jsfiddle.net/UEnqL/6/
正如您所看到的,beforeShow
回调正确地传入了元素和实例。 beforeshowDay
仅传入一个日期对象。
关于Jquery datepicker beforeShow 似乎没有传递实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12953878/