Disabling Previous and Next buttons in Mobile Safari

后端 未结 4 1675
有刺的猬
有刺的猬 2020-12-05 20:09

Is it possible to disable the \'next\' and \'previous\' buttons in Mobile Safari when focused on an input field? I\'ve been trying the method of setting all fields to

4条回答
  •  攒了一身酷
    2020-12-05 20:54

    So far the best solution for me (based on Jezen Thomas solution) is to set on focus readonly to inputs and textareas and disabled to selects, and remove them on blur:

    jQuery('input, textarea, select').on('focus', function() {
      jQuery('input, textarea').not(this).attr("readonly", "readonly");
      jQuery('select').not(this).attr("disabled", "disabled");
    });
    
    jQuery('input, textarea, select').on('blur', function() {
      jQuery('input, textarea').removeAttr("readonly");
      jQuery('select').removeAttr("disabled");
    });
    

    Only one flaw is that you need to drop focus (for example clicking on background) before changing from input / textarea to select. But you can easily change your focus between inputs and textareas.

提交回复
热议问题