Can a jQuery UI datepicker be matched to a click event's target?

I've written a simple jQuery (1.4.2) UI (1.8) widget that embeds a jQuery UI datepicker. I'd like to detect when a user clicks outside my widget, in which case it should automatically hide itself. My code looks roughly like this: var self = this; $(document).bind("click.mywidget": function(event) { var target = event.target; if (!self.container.has(target).length && target != self.container.get(0)) { self.hide(); } }); The problem comes when clicking on a date or month prev/next button in the datepicker. For some reason, even though Firebug shows those elements as being descendants of my container, the has() check fails for them. What is happening, and how might I fix this?
Are you sure that the datepicker is in the container? By default I've seen it be appended to the end of the page.

以上就是Can a jQuery UI datepicker be matched to a click event's target?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏