document.getElementById('btnid').disabled is not working in firefox and chrome

后端 未结 7 1190
醉梦人生
醉梦人生 2020-12-08 21:16

I\'m using JavaScript for disabling a button. Works fine in IE but not in FireFox and chrome, here is the script what I\'m working on:

function disbtn(e) { 
         


        
7条回答
  •  余生分开走
    2020-12-08 21:53

    Try setting the disabled attribute directly:

    if ( someCondition == true ) {
       document.getElementById('btn1').setAttribute('disabled', 'disabled');
    } else {
       document.getElementById('btn1').removeAttribute('disabled');
    }
    

提交回复
热议问题