单击onClick按钮后如何显示消息



我的onClick按钮在我点击后已经运行了一个函数,我只希望它在被点击后也显示一条确认消息。我只是被卡住了。任何帮助都会得到通知。这就是我的按钮的格式:

<button id="button" type="button" onClick={write}> 
RESERVE ROOM
</button>

只需创建一个写入函数,将消息添加到html元素

function write() {
const message = document.getElementById("message");
message.innerText = "This is the inserted message";
}

最新更新