选项的click事件在IE中不起作用 [英] click event for option doesn't work in IE

查看:66
本文介绍了选项的click事件在IE中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多选标记,我需要将其选项的功能写为onclick,因为我需要获取上次单击的选项的值,但是当我写以下内容时

I have a multiple select tag, and I need to write the function onclick of it's options, because I need to get the value of last clicked option, but when I wrote the following

$("#multiple_select option").click(function()
{
     var val = $(this).val();
     alert(val);
});

它在IE中不起作用.

出什么问题了?

我需要确切的click事件,因为我已经编写了一个onclick事件函数(演示此处),然后我需要修复上次更改的元素的值,如果没有click事件(我认为)

I need exactly click event, because I wrote a function onclick event already(demo here), and I need to fix last changed element's value, which is impossible to make without click event(I think)

推荐答案

不要在选项上绑定它

$("#multiple_select").click(function(){
     alert("works");
});


可接受的答案:


accepted answer:

$(document).ready(function()
{
    var options = $("#supply_cities_select :selected");
    var lastOption;
    $("#supply_cities_select").click(function()
        {
            lastOption = $(this).find(':selected').not(options);
            options = $(this).find(':selected');
        })
});

这篇关于选项的click事件在IE中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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