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

后端 未结 7 1185
醉梦人生
醉梦人生 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:54

    use setAttribute() and removeAttribute()

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

    SEE DEMO

提交回复
热议问题