js button_disabled.html

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js button_disabled</title>
</head>
<body>
<button id="button" disabled="disabled">0.点我无效!</button>
<button οnclick="this.disabled='true'; console.log(this.disabled);">1.Disable Me</button>
<script>
    /*参考:https://www.w3school.com.cn/tags/att_button_disabled.asp
    * https://www.runoob.com/tags/att-button-disabled.html*/
    function disableMyself() {
        // console.log("document.all:", document.all);
        // document.all.Btn1.disabled = true;
        document.getElementById("Btn1").disabled = true;
    }

    function enableBtn1() {
        // document.all.Btn1.disabled = false;
        document.getElementById("Btn1").disabled = false;
    }
</script>
<input id="Btn1" type="button" value="2.Btn1" onClick="disableMyself();">
<input type="button" value="enable Btn1" onClick="enableBtn1();">
</body>
</html>

        
        
发布了197 篇原创文章 · 获赞 61 · 访问量 11万+

猜你喜欢

转载自blog.csdn.net/weixin_42193179/article/details/105324916