I'm running into an issue while trying to develop a custom CSS and jQuery popup. Despite my efforts, the popup isn't functioning as intended. Take a look at my code below and point out where I may have gone wrong. What I aim to achieve is a popup that opens when the user clicks on the "Click Me" button, and closes when the user clicks outside of the popup.
jQuery has already been included in my code. Here's the code snippet:
<style>
.maskarea {
width: 100%;
height:700px;
background: rgba(255, 255, 255, .7);
position: fixed;
left: 0;
top: 0;
display:none;
}
.popup {
width: 300px;
height: 300px;
position: fixed;
left: 50%;
background: #ccc;
margin-left: -150px;
top: 50%;
margin-top: -150px;
}
</style>
<script>
$(function(){
$(".hit").click(function(){
$(".maskarea").show();
})
})
</script>
</head>
<body>
<a href="javascript:void(0)" class="hit">Click Me</a>
<div class="maskarea">
<div class="popup">
</div>
</div>
</body>