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

时间:2021-05-11 02:26:50

标签: javascript html button onclick

我的 onClick 按钮在我点击后已经运行了一个功能,我只是希望它在被点击后也显示一条确认消息。我只是被困住了。任何帮助是appriciated。 这是我的按钮的格式:

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

1 个答案:

答案 0 :(得分:0)

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

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

相关问题