I have a modal that pops out after sometime not when i click on a button, but i would like to permently close the modal and set it in a localstorage if that particular user does not want to see the modal again.
This is the code that i have written to try that
<script>
$(function() {
const showModal = localStorage.getItem("modal") === null;
$(".modal").toggleClass("d-none")
$(".modal_close").on("click",function() {
localStorage.setItem("modal","seen");
$(this).closest(".modal").addClass("d-none")
});
})
</script>
the modal
<div class="modal fade" style="background: rgba(0, 0, 0, 0.548);" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content animate-grad text-white">
<div class="modal-header text-center">
<h5 class="modal-title " style="text-align: center;" id="exampleModalLabel"><strong>{{follow_us.title}}</strong></h5>
<p style="border-top: 1px solid white;"></p>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
{% if follow_us.content %}
<div class="modal-body">
<p>{{ follow_us.content }}</p>
</div>
{% endif %}
<div class="d-flex text-white">
</div>
<div class="modal-footer w-100">
<a style="cursor: none;" class="modal_close close"> Do not show this again.</a>
</div>
</div>
</div>
</div>
i want to permanently close the modal when a clicks on the Do not show this again button. How do i achieve this?
2
Answers
I think you can change it like this
but I wonder if you could change the
id
of modalYou can try something like this.