JavaScipt
$(".card-container").on('click', function() {
$(this).fadeOut("fast");
});
CSS
<div class="card-container">
<div class="card-wrap">
<div class="card-content">
Lorem ipsum
</div>
</div>
</div>
I have a button that displays the card-container
and its child divs. (Similar to a modal on a webpage)
To close the card-container
, I only want it to disappear when a user clicks outside of the card-content
div. This prevents accidental closure if an input field inside is being used.
How can I achieve this so that the card-container
closes only when the card-container
or card-wrap
divs are clicked?