Just starting out with coding and working on a web app. Trying to add two buttons at the top of the page - one for login/create an account and the other for adding reviews. Successfully implemented the first button, which displays a modal when clicked. However, when I tried to add the second button, both buttons ended up displaying the same modal.
Both modals have a small 'x' at the top right corner for closing them, but it doesn't work now. Here's a snippet of my code:
The CSS styles are defined in the head section.
/* The Modal (background) */
.modal {
display: none;
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.3); /* Used to grey out the rest of the screen */
}
/* Modal Content */
.modal-content {
background-color: #fefefe; /* Background colour of Modal */
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 50%;
}
/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
</style>
The actual HTML code is inside the body section.
<h2>Modal Testing</h2>
<!-- Buttons to open Modals -->
<button id="loginBtn">Account</button>
<button id="reviewBtn">Add Review</button>
...