[英]Dropdown list selection not working properly in internet explorer
I have various dropdown lists, in a way that if we select first item should not show in second dropdown list for that I have written jquery like 我有各种下拉列表,在某种程度上如果我们选择第一项不应该显示在第二个下拉列表中我已经写了jquery像
$(document).ready(function() {
$('.ddlProjectvalue').change(function() {
updateDDLValues();
});
});
function updateDDLValues() {
// Display all
$('.ddlProjectvalue option').show();
// Hide all selected options from other selectlists
$('.ddlProjectvalue').each(function(i,element) {
var selectedvalue = $(element).find('option:selected').val();
$('.ddlProjectvalue').not(element).find('option[value="'+selectedvalue+'"]').hide();
});
}
as you can check jsfiddle.net , it is working fine in chrome and firefox but not working in internet explorer, what is the problem? 你可以检查jsfiddle.net ,它在chrome和firefox中工作正常,但不能在Internet Explorer中工作,有什么问题?
It seems that most browsers don't allow the hiding of an <option>. 似乎大多数浏览器都不允许隐藏<option>。 I think the way to go is to remove the <option> altogether. 我认为要走的路是完全删除<option>。
我发现了问题, $(element).find('option:selected').val()
此元素中的$(element).find('option:selected').val()
在IE中未定义,而在chrome中,正确的值即将到来
This Function is working Fine for Me in Only for Internet Explorer 仅适用于Internet Explorer,此功能对我来说很好
function updateDDLValues() {
// Display all
$('.ddlProjectvalue span option').unwrap();
// Hide all selected options from other selectlists
$('.ddlProjectvalue').each(function (i, element) {
var selectedvalue = $(element).find('option:selected').val();
$('.ddlProjectvalue').not(element).find('option[value="' + selectedvalue + '"]').wrap('<span style="display: none;">');
});
}
OR 要么
function updateDDLValues() {
$('.ddlProjectvalue span option').unwrap().show();
// Hide all selected options from other selectlists
$('.ddlProjectvalue').each(function (i, element) {
var selectedvalue = $(element).find('option:selected').val();
$('.ddlProjectvalue').not(element).find('option[value="' + selectedvalue + '"]').wrap('<span>').hide();
});
}
If we want to use other than IE, we can approach My above code(In My question) which was not supported by IE. 如果我们想使用除IE之外的其他代码,我们可以使用IE不支持的上述代码(在我的问题中)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.