I have a Modal that I am trying to open with the code below.
The modal opens fine and adds open
to the parent class. However, when I click 'close', it does not close and does not add close
to the class either.
Can anyone shed light on why this might be happening?
<script type="text/javascript">
jQuery(document).ready(function($) {
$window = $(window)
$(".modal-trigger").click(function(e) {
e.preventDefault()
var id = $(e.target).attr("href")
$(id).addClass("open")
$(id).find('.close').click(function(e) {
e.preventDefault()
$(e.target).parent().removeClass(".open")
});
})
});
</script>
Here is my Close
button in HTML:
<button class="close icon-close"></button>