Despite setting the display property of the div element with class layer to flex
, it is not being displayed on the DOM.
$("#elem").click(function(e) {
if (e.target.classList.contains("myClass")) {
$("*").hide();
$("body").prepend(`<div class="layer">Hey!</div>`);
}
});
.layer {
display: flex;
justify-content: center;
align-items: center;
background: rgb(55, 55, 55);
height: 100vh;
width: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<div id="elem" class="myClass">click me</div>