chrome中选择选项元素上的点击事件 [英] Click event on select option element in chrome
本文介绍了chrome中选择选项元素上的点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Chrome
中遇到以下问题:
I'm having a problem in Chrome
with the following:
var items = $("option", obj);
items.each(function(){
$(this).click(function(){
// alert("test");
process($(this).html());
return false;
});
});
click
事件似乎不会在 Chrome
中触发,但在 Firefox
中有效.
The click
event doesn't seem to fire in Chrome
, but works in Firefox
.
我希望能够在组合中的 option
元素上 click
,如果我使用另一种元素,例如 它工作正常.有任何想法吗?谢谢.
I wanna be able to click
on a option
element from a combo, if I do instead another kind of element, lets say <li>
it works fine. Any ideas? Thanks.
推荐答案
我认为单击事件对选项无效.但是,它对选择元素有效.试试这个:
I don't believe the click event is valid on options. It is valid, however, on select elements. Give this a try:
$("select#yourSelect").change(function(){
process($(this).children(":selected").html());
});
这篇关于chrome中选择选项元素上的点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文