dedi wibisono dedi wibisono - 17 days ago 5
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>
</div>


Here is my complete code:
https://jsfiddle.net/dedi_wibisono17/xn3npwc4/

What should I do? Thank You

Answer

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.

Comments