在我的代码中,我希望按钮可以单击一次。我在下方放置了 2 个按钮,因为我想在单击其中一个按钮时禁用另一个按钮。尽快帮忙非常感谢!
<div style = "position:absolute; left:625px; top:100px; background-color:white;">
<button type="button" onclick="alert('The guy walks away disapointed, I think I made the wrong decision')" >Detain</button>
<button type="button" onclick="alert('The guy sighs in relief and looked happy. The guards guide him to the exit. I think I made the right decision')">Free them</button>
</div>
用途:
this.style.display='none';
在要删除的 div 内的 onclick 内:
<body>
<div>
<button type='button' onclick="alert('message1'); this.style.display='none';">button1</button>
<button type='button' onclick="alert('message2')">button2</button>
</div>
</body>