下拉列表的 selectedindexchanged 事件不适用于 jquery

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6746752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 21:20:22  来源:igfitidea点击:

selectedindexchanged event of dropdownlist is not working with jquery

jqueryasp.net

提问by user851889

hello I have a dropdownlist. I am using jquery plugin to give style to dropdownlist. jquery plugin is jquery.dd.js. but my problem is selectedindexchangedevent is not working in Internet exlorer 8 although it is working fine in other browsers.

你好,我有一个dropdownlist。我正在使用 jquery 插件为dropdownlist. jquery 插件是jquery.dd.js。但我的问题是selectedindexchanged事件在 Internet exlorer 8 中不起作用,尽管它在其他浏览器中运行良好。

回答by kleinohad

try this:

尝试这个:

$('#yourSelectId').change(function() {
    var selectedVal = $('#yourSelectId option:selected').attr('value');
});

you will get the value inside selectedVal

您将获得 selectedVal 中的值

回答by RizzCandy

Think would be better to use .val()

认为使用 .val() 会更好

$('#yourSelectId').change(function() {
    var selectedVal = $('#yourSelectId').val();
});