Закройте всплывающее окно щелчком мыши в любом местеJquery

Программирование на jquery
Anonymous
Закройте всплывающее окно щелчком мыши в любом месте

Сообщение Anonymous »

Мне нужно отредактировать этот код так, чтобы, если пользователь щелкнет в любом месте всплывающего окна, оно закрывалось. Я думал, что могу просто удалить .popup-btn-close, но, похоже, это не сработало. Вот код открытия и закрытия
jQuery(document).on('click', '.sec-our-team .our-team-name .heading-title, .sec-our-team .our-team-name .pp-sub-heading', function(){
jQuery('.team-popup-main').fadeIn();
var color_class = jQuery(this).parents('.our-team-name').attr('class').split(' ').pop();
var headshot_url1 = jQuery(this).closest('.fl-col-content').find('.our-team-headshot .fl-photo-content img').attr('src');
if(jQuery(this).hasClass('pp-sub-heading')) {
var team_name1 = jQuery(this).parent('.pp-heading-content').find('.pp-heading .heading-title').text();
}else{
var team_name1 = jQuery(this).text();
}
var team_bio1 = jQuery(this).parents('.pp-heading-content').find('.pp-sub-heading .bio-full-content').html();
jQuery('.team-popup-main').addClass(color_class);
jQuery('.team-popup-main .popup-body .team-headshot img').attr('src',headshot_url1);
jQuery('.team-popup-main .popup-body .team-name').text(team_name1);
jQuery('.team-popup-main .popup-body .team-bio').html(team_bio1);
});
jQuery(document).on('click', '.sec-our-team .fl-col-content .our-team-headshot', function(){
jQuery('.team-popup-main').fadeIn();
var color_class = jQuery(this).parent('.fl-col-content').find('.our-team-name').attr('class').split(' ').pop();
var headshot_url2 = jQuery(this).find('img').attr('src');
var team_name2 = jQuery(this).parent('.fl-col-content').find('.our-team-name .heading-title').text();
var team_bio2 = jQuery(this).parent('.fl-col-content').find('.pp-sub-heading .bio-full-content').html();
jQuery('.team-popup-main').addClass(color_class);
jQuery('.team-popup-main .popup-body .team-headshot img').attr('src',headshot_url2);
jQuery('.team-popup-main .popup-body .team-name').text(team_name2);
jQuery('.team-popup-main .popup-body .team-bio').html(team_bio2);
});

jQuery(document).on('click', '.team-popup-main .popup-body .popup-btn-close', function(){
var lastClass = jQuery('.team-popup-main').attr('class').split(' ').pop();
jQuery('.team-popup-main').removeClass(lastClass);
jQuery('.team-popup-main').fadeOut();
});



Подробнее здесь: https://stackoverflow.com/questions/798 ... k-anywhere

Вернуться в «Jquery»