JQuery实现IE浏览器上不支持的option disable选项
可怜的IE,不支持select 中option的disabled属性 现在要做一个级联select菜单,前一个选择最小值,后一个选择最大值,利用JS可以实现在选择最小值后,将最大值中比最小值小的元素disabled。 可惜IE不支持disable="disabled"属性。
参考URL如下: http://dennisbloete.de/tags/jquery/
利用JQuery实现了IE中diabled属性
$(document).ready(function(){
// Disabled options fix for Internet Explorer
$('select').each(function(){
this.rejectDisabled = function(){
if (this.options[this.selectedindex].disabled){
if (this.lastSelectedIndex) {
this.selectedIndex = this.lastSelectedIndex;
} else {
var first_enabled = $(this).children('option:not(:disabled)').get(0);
this.selectedIndex = first_enabled ? first_enabled.index : 0;
}
} else {
this.lastSelectedIndex = this.selectedIndex;
}
};
this.rejectDisabled();
this.lastSelectedIndex = this.selectedIndex;
$(this).children('option[disabled]').each(function(){
$(this).css('color', '#CCC');
});
$(this).change(function() {
this.rejectDisabled();
});
});
});