How can i hide the bpopup jquery using a button? i have an ajax response that if the data return error has failed bpopup will be called. then inside my bpopup i have a "Got it!" button when the user click it, it will just close the bpopup
$.ajax({
url: 'my_url',
type: "POST",
success: function(data){
if(data.error == 'failed){
$('#popup').bPopup({
modalClose: false,
opacity: 0.6,
positionStyle: 'fixed'
});
//then my bpopup has a button "Got it!"
$('.gotit').click(function(e) {
//Code the will hide the bpopup.
}
}
}
})
i have tried $('#popup).hide(); but it does not completely closed the bpopup.
BTW here's my popup html.
<div id="popup" style="display: none; min-width: 350px;">
<span class="button b-close"><span>X</span></span>
<div class="col-lg-12">
<p><span class="ui-icon ui-icon-alert"></span> The Code does not match the information provided.</p>
<button class="btn btn-primary btn-sm pull-right gotit">Got it</button>
</div>
</div>
First of all
if(data.error == 'failed){here'is missed so add it and make it:-if(data.error == 'failed'){Closing pop-up can do it in two ways
1.Hide the pop-up directly.
Example:-
2.Trigger close button click event of pop-up (if close button code is already written and working)
Example:-