Disable and enable an html button using JavaScript/jQuery:
Suppose in html:
<button id="btnSave">Save</button>
Using JavaScript:
To Disable an html button-
document.getElementById("btnSave").disabled=true
To Enable an html button-
document.getElementById("btnSave").disabled=false
Using jQuery:
To Disable an html button-
$("#btnSave").attr("disabled","disabled");
or
$("#btnSave").prop("disabled",true);
To Enable an html button-
$("#btnSave").removeAttr("disabled","disabled");
or
$("#btnSave").prop("disabled",false);
Suppose in html:
<button id="btnSave">Save</button>
Using JavaScript:
To Disable an html button-
document.getElementById("btnSave").disabled=true
To Enable an html button-
document.getElementById("btnSave").disabled=false
Using jQuery:
To Disable an html button-
$("#btnSave").attr("disabled","disabled");
or
$("#btnSave").prop("disabled",true);
To Enable an html button-
$("#btnSave").removeAttr("disabled","disabled");
or
$("#btnSave").prop("disabled",false);
Comments
Post a Comment