我想追加jQuery UI的,日期选择器,我不能让事件处理工作:通过多条链路jQuery的事件处理程序将无法正常工作
$('.ui-datepicker').on('click', 'a.ui-datepicker-next', 'a.ui-datepicker-prev', function(event) {
event.preventDefault();
console.log("CLICK");
});
我没有什么记录到控制台,当我点击链接。这里是html:
<div id="ui-datepicker-div" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"...>
<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix- ui-corner-all">
<a class="ui-datepicker-next ui-corner-all"...></a>
<a class="ui-datepicker-prev ui-corner-all"...></a>
...
什么我需要把事件处理程序作为触发器? jQuery位于我的html页脚的<script>jQuery here</script>
中。
编辑:链接是不正确的 - a.ui-datepicker-month
和a.ui-datepicker-year
变更为a.ui-datepicker-next
和a.ui-datepicker-prev
感谢
更正语法。仍然没有登录到控制台,虽然.... @Rory McCrossan –
你的代码没有什么特别的错误。这个问题必须与事件的附加方式有关。执行上面的代码时,'.ui-datepicker'元素是否存在?作为一个测试,尝试用'$(document)'替换'$('。ui-datepicker')' –
编辑中的''元素都没有'ui-datepicker-month'或'ui-日期选择器,year' ...? –