Close the alert div only after clicking the X button a number of times

<div class="alert">
        <span id="button" class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
        This is an alert box.
</div>

I tried using the alert function but I learned that you can’t manipulate it so I created an alert div but I don’t know how to achieve the title.