chrome中选择选项元素上的单击事件 [英] Click event on select option element in chrome

查看:42
本文介绍了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.

我希望能够 click 组合中的 option 元素,如果我改为使用另一种元素,可以说 <li> 它工作正常.有任何想法吗?谢谢.

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.

推荐答案

我不相信 click 事件对选项有效.但是,它在选择元素上是有效的.试试这个:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆