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

查看:128
本文介绍了点击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;
    });
});

点击事件似乎没有fire < Chrome ,但可以在 Firefox 中使用。

The click event doesn't seem to fire in Chrome, but works in Firefox.

我希望能够点击在组合中的选项元素上,如果我这样做,而不是另一种元素,让我们说< 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.

推荐答案

我不相信点击事件对选项有效。但是,它对选择的元素有效。试试看:

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天全站免登陆