[英]window onload call magnificpopup
我有一個腳本功能,可以在單擊標簽時正常工作,當我在站點加載或身體加載時需要調用該函數。
這是我使用的代碼
<div class="html-code">
<a href="#test-modal" class="popup-modal">Open modal</a>
<div class="white-popup-block mfp-hide" id="test-modal">
<span>hi</span>
<p><a href="#" class="popup-modal-dismiss">Dismiss</a></p>
</div>
</div>
<script type="text/javascript">
$(function () {
$('.popup-modal').magnificPopup({
type: 'inline',
preloader: true,
focus: '#username',
modal: true
});
$(document).on('click', '.popup-modal-dismiss', function (e) {
e.preventDefault();
$.magnificPopup.close();
});
});
</script>
您是否嘗試將其插入
$(document).ready(function() { ... }
並調用open()方法?
$(document).ready(function() {
$('.popup-modal').magnificPopup({
type: 'inline',
preloader: true,
focus: '#username',
modal: true
}).open();
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.