I'm facing some challenges while trying to develop a modal that pops up when a specific section of an image map is clicked.
Here is the snippet from my HTML file:
<head link rel="stylesheet" href="ryanspagecss.css"></head>
<body>
<div class="main">
<script src="lotrpage.js"></script>
<map name="lotrmap">
<area shape="poly" href="" coords="405, 50, 463, 80, 461, 141, 408, 173, 354, 144, 353,81" onclick="playerSelect()">
</map>
<div id="selectModal" class="selectModal">
<p>Content inside the modal...</p>
</div>
Below is the CSS code:
#selectModal {
width: 500px;
overflow: hidden;
background: pink;
box-shadow: 0 0 10px black;
border-radius: 10px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 9999;
padding: 10px;
text-align: center;
display: none;
}
And here is the JavaScript part:
function playerSelect(){
//Show Modal
let selectModal = document.getElementById('selectModal');
selectModal.style.display = "block";
}
I know I should change the display value from none to block in order to show the Div element, and this is what my JavaScript function aims to achieve. However, clicking on the image doesn't trigger any action. What could be missing in this implementation?