Мне нужно отредактировать этот код так, чтобы, если пользователь щелкнет в любом месте всплывающего окна, оно закрывалось. Я думал, что могу просто удалить .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
Программирование на jquery
-
Anonymous
1766137455
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();
});
Подробнее здесь: [url]https://stackoverflow.com/questions/79850987/close-popup-with-a-click-anywhere[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия