jquery ui datepicker 选定一个日期后执行一段函数代码怎么写

$('#book_date2').datepicker({ onSelect: function(dateText, inst) {
calc()

} });
为什么函数无法执行触发?

加个alert看看,onSelect是会触发的,看看是不是你调用的函数有问题。追问

直接写alert()也没反应,要不给个demo

追答

html

<div id="book_date2"></div>

js

$('#book_date2').datepicker({ onSelect: function(dateText, inst) {
alert(1)
} });

温馨提示:内容为网友见解,仅供参考
第1个回答  2018-05-18

没问题;

放到加载页面后运行的函数里面即可:

$(document).ready(function(){你需要运行的函数;})

相似回答