Jquery Disable option in dropdown

前端 未结 2 1542
孤独总比滥情好
孤独总比滥情好 2021-01-05 09:53

Guys i have used the following code to disable an option using jQuery (jquery-1.4.2.min).The disable happens in Firefox , but not in IE.

&l         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-05 10:32

    I think i might be wrong but it could be because the select rather than option can be disabled. Since firefox is great and IE sucks, well you can guess why :) you having that problem. Use css to grey out the text of that option.

    then on jquery do something like this.

    $('#SCOPE').change(function(){
      if($('#SCOPE option[value="'+$(this).val()+'"]').attr('disabled') == 'disabled'){
        alert('Its disabled you cannot select this option');
      }
    });
    

    BTW. double check the code as I have not tested this :)

提交回复
热议问题