Disable select option in IOS Safari

后端 未结 5 2018
别那么骄傲
别那么骄傲 2020-12-01 13:17

I\'ve implemented a form which needs to disable certain options in a select box using Javascript. It works fine in all browsers but not in Safari on IOS (Desktop Safari does

5条回答
  •  -上瘾入骨i
    2020-12-01 13:32

    I have a solution that may be helpful for you too, and it doesn't requires jQuery...

    My problem was that the options were dynamically enabled and disabled, so the idea of removing the options by jQuery avoided them to be reused.

    So my solution was to modify the innerHTML like this:

    function swapAvailOpts(A, B) {
      content = document.getElementById(B);
      switch (A) {
        case "X":
          content.innerHTML = '';
          break;
        case "Y":
          content.innerHTML = '';
          break;
        default:
          content.innerHTML = '';
      }
    }
    
    

提交回复
热议问题