javascript - Is it possible to permanently disable html buttons? -
i'm new programming don't know much, wondering if there way permanently disable button. i've used this:
document.getelementbyid("whatevertheidis").disabled = true;
but @ parts of document reverse using this:
document.getelementbyid("whatevertheidis").disabled = false;
i need can override that, , permanently disable button. there way this?
there 1 way disable or enable button. so, if you're looking separate way permanently disable button (yet leave visible) override setting .disabled
true - there no such property or feature button.
there many ways fix code. example, when want permanently disable button, can set custom attribute on button , everywhere think enabling button, can check custom attribute , if it's set, don't enable button.
other options consider hiding button or removing button dom.
you can fix code making own permanent disable in own code. if, rather manipulating .disabled
property directly, switch using these functions, code respect .permdisabled
property.
function getelem(elem) { if (typeof elem === "string") { elem = document.getelementbyid(elem); } return elem; } function disablebuttonpermanent(elem) { elem = getelem(elem); elem.disabled = true; elem.permdisabled = true; } function disablebutton(elem) { elem = getelem(elem); elem.disabled = true; } function enablebutton(elem) { elem = getelem(elem); if (!elem.permdisabled) { elem.disabled = false; } }
Comments
Post a Comment