dedi wibisono dedi wibisono - 5 months ago 35
CSS Question

Can't Create more than one Button Modal

I duplicate my modal button and The problem is I can't show "Open Modal 2" in my code.

<button id="myBtn">Open Modal</button>
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<p>Some text in the Modal..</p>

Here is my complete code:

What should I do? Thank You


You should use different ID for your "Open Modal 2" elements.

According to definition and usage from W3School,

the getElementById() method accesses the first element with the specified id.