Shift+点击事件问题
我确信我正在做一些非常愚蠢的事情,因此无法正常工作,但我无法让我的轮班事件触发。我已经尝试过:
$('.ShowCannedReport_UserFilterDropdown').each(function (index, element) {
$(element).bind('click', function (event) {
if (!event.shiftKey && !event.ctrlKey) {
ShowCannedReport_UserFilter_Blur(this, event);
}
else {
ShowCannedReport_UserFilterWithShiftHeld = this;
}
});
和:
$('.ShowCannedReport_UserFilterDropdown').each(function (index, element) {
$(element).click(function (event) {
if (!event.shiftKey && !event.ctrlKey) {
ShowCannedReport_UserFilter_Blur(this, event);
}
else {
ShowCannedReport_UserFilterWithShiftHeld = this;
}
});
});
这两个都显示 event.shiftkey 为未定义。知道我做错了什么吗?
ShowCannedReport_UserFilterDropdown 是一个多选下拉列表,并且 click 事件在两个版本上都会触发,但 Shiftkey 事件从未注册。
I'm sure i'm doing something terribly stupid for this not to work, but I can't get my shift event to fire. I've tried both:
$('.ShowCannedReport_UserFilterDropdown').each(function (index, element) {
$(element).bind('click', function (event) {
if (!event.shiftKey && !event.ctrlKey) {
ShowCannedReport_UserFilter_Blur(this, event);
}
else {
ShowCannedReport_UserFilterWithShiftHeld = this;
}
});
and:
$('.ShowCannedReport_UserFilterDropdown').each(function (index, element) {
$(element).click(function (event) {
if (!event.shiftKey && !event.ctrlKey) {
ShowCannedReport_UserFilter_Blur(this, event);
}
else {
ShowCannedReport_UserFilterWithShiftHeld = this;
}
});
});
Both of these show the event.shiftkey as undefined. Any idea as to what i'm doing wrong?
ShowCannedReport_UserFilterDropdown is a multiselect dropdown and the click event is firing on both versions, but the shiftkey event is never registered.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能确定您的初始选择器正在工作吗?即:
文档就绪事件处理程序中的代码是否可用?
我已经设置了一个 jsFiddle 来模仿您想要实现的目标,并且一切正常:
http://jsfiddle.net/xT4ke/
另外,当 jQuery 这样做时,为什么要迭代每个项目对你来说,这应该足够了:
Can you be sure that your initial selector is working? I.e:
Is the code inside the document ready event handler?
I've set up a jsFiddle that mimics what you are trying to achive, and all works ok:
http://jsfiddle.net/xT4ke/
Also, why are you iterating through each item when jQuery does that for you, This should suffice: