我需要一些帮助隐藏我的模态。在我的按钮onclick上我运行内置的showModal()
函数打开我的弹出窗口。由于showModal()
已经存在,我认为会有一个类似的内置函数,如hideModal()
。隐藏模态反应
如果我按下退出键,窗口将关闭,所以我想知道按ESC时会发生什么。这是我用来显示它的功能:
modal(e) {
e.preventDefault();
document.getElementById("myDialog").showModal();
}
这里是元素即时试图显示/隐藏:
<dialog id="myDialog">
Namn:
<input className="modalInput" /><br />
Ålder:
<input className="modalInput" /><br />
Ras:
<input className="modalInput" /><br />
Beskrivning:
<textarea /><br />
<button className="confirmBooking" onClick=
{this.bookingBtn}>Boka</button>
<button className="closeModal" onClick={this.closeModal}>X</button><br
/>
{this.state.bokning}
</dialog>
容易,尽量接近() 的onClick = {this.close()} 但这个按钮必须INSIDE模式。 –