Дополнительная кнопка закрытия Fancybox

Azazello77

Полезный
Регистрация
16 Май 2015
Сообщения
213
Реакции
16
<button type="button" id="buttonclosed" class="btn btn-default" >Закрыть</button>

<script type='text/javascript'>
$(document).on('click', '#buttonclosed', function() {
$.fn.fancybox.close();
});
</script>

Но при нажатии на кнопку получаю соответственно в консоли хрома
Код:
(index):156 Uncaught TypeError: Cannot read property 'close' of undefined
    at HTMLButtonElement.<anonymous> ((index):156)
    at HTMLDocument.dispatch (jquery.min.js:3)
    at HTMLDocument.r.handle (jquery.min.js:3)
(anonymous) @ (index):156
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3
 
Выложите полность код страницы.
 
удалено
 
Последнее редактирование:
Но при нажатии на кнопку получаю соответственно в консоли хрома
Код:
(index):156 Uncaught TypeError: Cannot read property 'close' of undefined
    at HTMLButtonElement.<anonymous> ((index):156)
    at HTMLDocument.dispatch (jquery.min.js:3)
    at HTMLDocument.r.handle (jquery.min.js:3)
(anonymous) @ (index):156
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3
Так попробуйте:
Код:
jQuery.fancybox.close()


// или так:

jQuery('#fancybox-close').trigger('click')
 
Назад
Сверху