列表框选项上的双击事件在 IE 中未触发
我想将一个事件附加到列表框中的选项标签,以便当我单击其中一个选项标签时,它会移动到另一个列表框。
我有这样的代码:
$('#' + opts.leftListId + ' > option').live('dblclick', function () {
// Move the object
});
在 Firefox 中工作正常,但在 IE 中该事件根本不会被触发。我无法在选择节点上双击,因为我只需要移动被单击的节点。 有什么想法吗?
I want to attach an event to the option tags in a list box so that when I click one of them, it moves to another list box.
I have this code:
$('#' + opts.leftListId + ' > option').live('dblclick', function () {
// Move the object
});
Works fine in Firefox, but in IE the event is not fired at all. I can't use double click on the select node, because I need to move only the one that was clicked on.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您尝试将它们添加到选项元素,无论您如何添加,Doubleclick 都不会在 ie 上触发。我在 IE 中所做的唯一事情是将事件监视添加到选择本身,然后查看所选元素:
Doubleclick won't fire on ie if you try to add them to option elements, no matter how you add it. The only thing that I've got working in IE is to add the event watch to the select itself and then to look at selected elements:
请尝试以下操作:
更新 (10:21 GMT)
尝试取消直播:
请参阅此示例 - http://jsfiddle.net/hr7Gd/
更新 (10:45 GMT)
您的另一个选择是运行
dblclick()
在选择上(有效!)并且已选择获取 wich 值选项并使用该选项:请参阅此处的示例 - http://jsfiddle.net/hr7Gd/1/
Try this instead:
Update (10:21 GMT)
Try taking out the live:
See this example - http://jsfiddle.net/hr7Gd/
Update (10:45 GMT)
Your other option is to run the
dblclick()
on the select (which works!) and the get the vale of wich option has been selected and work with that:See this example working here - http://jsfiddle.net/hr7Gd/1/
明白了 - 我错误地认为我无法使用选择的双击事件。
这是工作代码:
我认为这行不通的原因是我认为它会移动所有选定的元素,而不仅仅是单击的元素。但是,双击的第一次单击似乎仅选择了一个元素,然后该事件在双击时触发并将其移动。
Got it - I was wrong thinking that I couldn't use the select's double click event.
This is the working code:
The reason I didnt think that this would work is that I thought it would move over all selected elements rather than just the one clicked on. However, it appears that the first click of a double-click selects only the one element, before this event fires on double click and moves it across.