dedi wibisono dedi wibisono - 1 year ago 74
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download